Bug #61230 "The provider did not return a ProviderManifestToken string." EF4 VS2010
Submitted: 19 May 2011 15:50 Modified: 4 Aug 2011 15:17
Reporter: Edwin Beltran Email Updates:
Status: Closed Impact on me:
None 
Category:Connector / NET Severity:S3 (Non-critical)
Version:6.3.6 OS:Windows (7 Ultimate x64)
Assigned to: Fernando Gonzalez.Sanchez CPU Architecture:Any
Tags: .Net 6.3.6, EF4, MySQL 5.5.12

[19 May 2011 15:50] Edwin Beltran
Description:
Hi this is my configuration:

MySQL 5.5.12
.Net Connection 6.3.6
Entity Framework 4
Visual Studio 2010 - ASP.Net MVC 3

Using Code First Approach, I trying to use EF4 and when trying to access the model object, an exception is thrown: "The provider did not return a ProviderManifestToken string.". With MSSQL works without a problem.

I did some research and apparently MySQL does not support EF4. Is this correct? if so, do you have an ETA of when will this option be available?

How to repeat:
- Create ASP.Net MVC 3 Project
- Create Model Class with some properties in it; ex. id, name, address, etc.
- Create Class Inhering DbContext Class and create two property object as type DbSet
- Create Controller and in the Index ActionResult create an object referencing the previous Class. 
- Compile the project.
- Create a View Inside the Index ActionResult, strongly typed and referencing the Model Class, and mark to crate an scaffold list template.
- run the project, the the compiler reach the line: " @For Each item In Model " you will get the error I am saying.
[20 May 2011 11:49] Richard Deeming
You'll get this exception if you can't connect to the server or database specified in your connection string. 

The current version of the MySql Connector/Net doesn't support creating the database from the model, so you'll need to create it manually before running your application. Once you've done that, it should work with EF4.1 without any problems.
[20 May 2011 14:52] Edwin Beltran
Do i have to create the entire db with tables and records?

Because, I already tried creating only the schema, and gives the same error...
[20 May 2011 19:44] Richard Deeming
AFAIK, you have to created the tables manually. The connector doesn't override the necessary methods to support generating the database automatically.
[30 Jun 2011 21:21] Igor Ilkevich
Guys, it doesn't works with EF4 even if DB exists.
I simply can not "Update model from database" at all. It throws this exception.
However I can browse DB through "Server Explorer" with the same connString but can't fill EF model.

I have tried both versions of the connector available at the moment: 6.3.7 and v6.4.2rc with no luck.
EF version is 4.1.
I am running 64bit Windows7 while connector installer says 32bit. Maybe this is what causes the issue?

Would be nice to have ETA for this because it just blocks any attempts to try mysql in modern .net projects.
[4 Aug 2011 15:17] Fernando Gonzalez.Sanchez
Thank you for your bug report. This issue has already been fixed in the latest released version of that product, which you can download at

  http://www.mysql.com/downloads/

This has been fixed in 6.4.4 and 6.3.8.
[16 Aug 2011 3:52] fuck off
This is not fixed in 6.4.4. I am having the exact same problem.
[16 Aug 2011 19:43] Fernando Gonzalez.Sanchez
Please check again which version are you using, we have not released yet 6.4.4 neither 6.3.8 versions of Connector/NET.

However if you are interested in getting the fix, from the source code, locate the file ProviderServices.cs and change the methods
private string GetTableCreateScript(EntitySet entitySet) and 
protected override string GetDbProviderManifestToken(DbConnection connection)

as shown below:

protected override string GetDbProviderManifestToken(DbConnection connection)
        {
            // we need the connection option to determine what version of the server
            // we are connected to
            MySqlConnectionStringBuilder msb = new MySqlConnectionStringBuilder(connection.ConnectionString);
            msb.Database = null;
            using (MySqlConnection c = new MySqlConnection(msb.ConnectionString))
            {
                c.Open();                
		        double version = double.Parse(c.ServerVersion.Substring(0, 3), CultureInfo.InvariantCulture);
                if (version < 5.0) throw new NotSupportedException("Versions of MySQL prior to 5.0 are not currently supported");
                if (version < 5.1) return "5.0";
                if (version < 5.5) return "5.1";
                return "5.5";
            }
        }

private string GetTableCreateScript(EntitySet entitySet)
        {
            EntityType e = entitySet.ElementType;            
                
            StringBuilder sql = new StringBuilder("CREATE TABLE ");
            sql.AppendFormat("`{0}`(", 
                (string)entitySet.MetadataProperties["Table"].Value == null ? 
                e.Name : (string)entitySet.MetadataProperties["Table"].Value);
            string delimiter = "";
            bool hasPK = false;
            foreach (EdmProperty c in e.Properties)
            {
                Facet facet;
                hasPK = hasPK ||
                    (c.TypeUsage.Facets.TryGetValue("StoreGeneratedPattern", false, out facet) &&
                    facet.Value.Equals(StoreGeneratedPattern.Identity));
                sql.AppendFormat("{0}{1}\t`{2}` {3}{4}", delimiter, Environment.NewLine, c.Name,
                    GetColumnType(c.TypeUsage), GetFacetString(c));
                delimiter = ", ";
            }
            sql.AppendLine(");");
            sql.AppendLine();
            if (!hasPK && e.KeyMembers.Count > 0)
            {
                sql.Append(String.Format(
                    "ALTER TABLE `{0}` ADD PRIMARY KEY (", e.Name));
                delimiter = "";
                foreach (EdmMember m in e.KeyMembers)
                {
                    sql.AppendFormat("{0}{1}", delimiter, m.Name);
                    delimiter = ", ";
                }
                sql.AppendLine(");");
                sql.AppendLine();
            }
            return sql.ToString();
        }
[4 Sep 2011 19:50] Konstantin Dombrugov
not sure, but maybe you forgot to fix this too in ProviderManifest.cs:

private XmlReader GetStoreSchemaDescription()
        {
            double version = double.Parse(manifestToken, CultureInfo.InvariantCulture);
[27 Sep 2011 8:22] Carno Mercado
I got same error using 6.4.4.0 connector when I update my model from db.
i am using win 7 64 bit; mysql 5.5.15.

the model was generated using 6.3.6.0 connector in win 7 32 bit. I upgraded to 6.4.4.0 due to timestamp field not handled by 6.3.6.0.

but now I cant update my model to add addl tables .
[27 Sep 2011 20:32] Fernando Gonzalez.Sanchez
Thanks for your comment Konstantin, actually that change was implemented as part of fix for http://bugs.mysql.com/bug.php?id=61901.
[27 Sep 2011 20:34] Fernando Gonzalez.Sanchez
Thanks for your feedback Carno,

I have a couple of comments:
1) First the fact that you are trying to update the model from the database means, your are not usign EF code-first (but rather database-first). So the fix for this doesn't apply (the scenario was specifically code first). I would suggest openning a different bug to track this.
2) However, the most important thing is that I tried to repro your problem using VS2008 and both 6.3.6 & 6.4.4 in a database-first scenario and couldn't repro. Could you provide more details on who to repro (ideally if you can isolate the issue to a small project and upload the whole project and related sql scripts, that would be the best.)
  
Thanks.
[28 Sep 2011 5:30] Carno Mercado
Thanks, I tried to make a small test project and it ran fine. Web application and Web Folder style. Both was able to create the edmx file and I can also update again from DB either delete or add new tables to the model.

Win 7 64 bit ultimate, vs2010 sp1, mysql 5.5.15-log
[29 Sep 2011 1:43] Carno Mercado
Found the culprit, make sure the connection string should have the "Persist Security Info=True" option.

I can now refresh my model from DB, hope this helps others.
[21 May 2012 19:15] Dinakar Choppa
Try having connection string name same as the dbcontext instance.

For reference: http://blogs.msdn.com/b/adonet/archive/2011/01/27/using-dbcontext-in-ef-feature-ctp5-part-...