Bug #68913 entity framework 5.0 (.net 4.0) with MySQL Connector/Net 6.7.0 Alpha
Submitted: 10 Apr 2013 3:26 Modified: 28 Jun 2013 5:10
Reporter: Paulo Finamori Email Updates:
Status: Closed Impact on me:
None 
Category:Connector / NET Severity:S2 (Serious)
Version:6.7.0 Alpha OS:Windows (Windows 7)
Assigned to: Gabriela Martinez Sanchez CPU Architecture:Any
Tags: Connector/Net 6.7.0, entity framework, entity framework 5.0, MySQL Connector/Net 6.7.0 Alpha

[10 Apr 2013 3:26] Paulo Finamori
Description:
I'm trying to use migration on entity framework 5.0 with MySQL Connector/Net 6.7.0 Alpha! I tested, but now I receive the following error message: 

Method not found: 'System.DateTime System.Data.Entity.Migrations.Model.InsertHistoryOperation.get_CreatedOn()'.

How to repeat:
I tried with both! Add-Migration with Update-Migration, and AutomaticMigrationsEnabled... Look the example below: 

Models: 
------- 

public class Produto 
{ 
public Produto() 
{ 

Categoria = new Categoria(); 
} 

[Key] 
[DatabaseGeneratedAttribute(DatabaseGeneratedOption.Identity)] 
public int ID { get; set; } 
public string Nome { get; set; } 
public Categoria Categoria { get; set; } 

public int ColunaTeste { get; set; } // This is the column for migration 
} 

public class Categoria 
{ 
[Key] 
[DatabaseGeneratedAttribute(DatabaseGeneratedOption.Identity)] 
public int ID { get; set; } 
public string Nome { get; set; } 

} 

Context: 
-------- 

public class Contexto : DbContext 
{ 
public Contexto() 
: base("Contexto") 
{ 
Database.SetInitializer(new 
//DropCreateDatabaseAlways<Contexto>() 
MigrateDatabaseToLatestVersion<Contexto, Configuration>() 
); 
} 

public DbSet<Produto> Produto { get; set; } 
public DbSet<Categoria> Categoria { get; set; } 

protected override void OnModelCreating(DbModelBuilder modelBuilder) 
{ 

modelBuilder.Conventions.Remove<IncludeMetadataConvention>(); 
modelBuilder.Conventions.Remove<PluralizingTableNameConvention>(); 

} 

} 

Configuration (Enable-Migrations): 
--------------------------------- 

internal sealed class Configuration : DbMigrationsConfiguration<TesteEF5_Migration.Contexto> 
{ 
public Configuration() 
{ 
AutomaticMigrationsEnabled = true; 
AutomaticMigrationDataLossAllowed = true; 
SetSqlGenerator("MySql.Data.MySqlClient", new MySql.Data.Entity.MySqlMigrationSqlGenerator()); 
} 

protected override void Seed(TesteEF5_Migration.Contexto context) 
{ 
} 
} 

InitialCreate(Enable-Migrations): 
--------------------------------- 

public partial class InitialCreate : DbMigration 
{ 
public override void Up() 
{ 
CreateTable( 
"dbo.Produto", 
c => new 
{ 
ID = c.Int(nullable: false, identity: true), 
Nome = c.String(unicode: false), 
Categoria_ID = c.Int(), 
}) 
.PrimaryKey(t => t.ID) 
.ForeignKey("dbo.Categoria", t => t.Categoria_ID) 
.Index(t => t.Categoria_ID); 

CreateTable( 
"dbo.Categoria", 
c => new 
{ 
ID = c.Int(nullable: false, identity: true), 
Nome = c.String(unicode: false), 
}) 
.PrimaryKey(t => t.ID); 

} 

public override void Down() 
{ 
DropIndex("dbo.Produto", new[] { "Categoria_ID" }); 
DropForeignKey("dbo.Produto", "Categoria_ID", "dbo.Categoria"); 
DropTable("dbo.Categoria"); 
DropTable("dbo.Produto"); 
} 
} 

Controller: 
----------- 

public class HomeController : Controller 
{ 
public ActionResult Index() 
{ 

List<Categoria> returnValue = null; 

try 
{ 
using (var ctx = new Contexto()) 
{ 
var query = ctx.Categoria.ToList(); 

returnValue = new List<Categoria>(); 

if (query.Count() > 0) 
returnValue.AddRange(query); 
} 

} 
catch (Exception ex) 
{ 
throw ex; 
} 

return View(); 
} 
} 

Web.Config: 
----------- 

<?xml version="1.0" encoding="utf-8"?> 
<!-- 
For more information on how to configure your ASP.NET application, please visit 
http://go.microsoft.com/fwlink/?LinkId=169433 
--> 
<configuration> 
<configSections> 
<!-- For more information on Entity Framework configuration, visit http://go.microsoft.com/fwlink/?LinkID=237468 --> 
<section name="entityFramework" type="System.Data.Entity.Internal.ConfigFile.EntityFrameworkSection, EntityFramework, Version=4.4.0.0, Culture=neutral, PublicKeyToken=b77a5c561934e089" requirePermission="false" /> 
</configSections> 
<connectionStrings> 
<add name="Contexto" connectionString="Server=localhost; Database=testemigrations; Uid=root;" providerName="MySql.Data.MySqlClient" /> 
</connectionStrings> 
<appSettings> 
<add key="webpages:Version" value="2.0.0.0" /> 
<add key="webpages:Enabled" value="false" /> 
<add key="PreserveLoginUrl" value="true" /> 
<add key="ClientValidationEnabled" value="true" /> 
<add key="UnobtrusiveJavaScriptEnabled" value="true" /> 
</appSettings> 
<system.web> 
<compilation debug="true" targetFramework="4.0" /> 
<authentication mode="Forms"> 
<forms loginUrl="~/Account/Login" timeout="2880" /> 
</authentication> 
<pages> 
<namespaces> 
<add namespace="System.Web.Helpers" /> 
<add namespace="System.Web.Mvc" /> 
<add namespace="System.Web.Mvc.Ajax" /> 
<add namespace="System.Web.Mvc.Html" /> 
<add namespace="System.Web.Optimization" /> 
<add namespace="System.Web.Routing" /> 
<add namespace="System.Web.WebPages" /> 
</namespaces> 
</pages> 
</system.web> 
<system.webServer> 
<validation validateIntegratedModeConfiguration="false" /> 
<modules runAllManagedModulesForAllRequests="true" /> 
<handlers> 
<remove name="ExtensionlessUrlHandler-ISAPI-4.0_32bit" /> 
<remove name="ExtensionlessUrlHandler-ISAPI-4.0_64bit" /> 
<remove name="ExtensionlessUrlHandler-Integrated-4.0" /> 
<add name="ExtensionlessUrlHandler-ISAPI-4.0_32bit" path="*." verb="GET,HEAD,POST,DEBUG,PUT,DELETE,PATCH,OPTIONS" modules="IsapiModule" scriptProcessor="%windir%\Microsoft.NET\Framework\v4.0.30319\aspnet_isapi.dll" preCondition="classicMode,runtimeVersionv4.0,bitness32" responseBufferLimit="0" /> 
<add name="ExtensionlessUrlHandler-ISAPI-4.0_64bit" path="*." verb="GET,HEAD,POST,DEBUG,PUT,DELETE,PATCH,OPTIONS" modules="IsapiModule" scriptProcessor="%windir%\Microsoft.NET\Framework64\v4.0.30319\aspnet_isapi.dll" preCondition="classicMode,runtimeVersionv4.0,bitness64" responseBufferLimit="0" /> 
<add name="ExtensionlessUrlHandler-Integrated-4.0" path="*." verb="GET,HEAD,POST,DEBUG,PUT,DELETE,PATCH,OPTIONS" type="System.Web.Handlers.TransferRequestHandler" preCondition="integratedMode,runtimeVersionv4.0" /> 
</handlers> 
</system.webServer> 
<runtime> 
<assemblyBinding xmlns="urn:schemas-microsoft-com:asm.v1"> 
<dependentAssembly> 
<assemblyIdentity name="System.Web.Helpers" publicKeyToken="31bf3856ad364e35" /> 
<bindingRedirect oldVersion="1.0.0.0-2.0.0.0" newVersion="2.0.0.0" /> 
</dependentAssembly> 
<dependentAssembly> 
<assemblyIdentity name="System.Web.Mvc" publicKeyToken="31bf3856ad364e35" /> 
<bindingRedirect oldVersion="0.0.0.0-4.0.0.0" newVersion="4.0.0.0" /> 
</dependentAssembly> 
<dependentAssembly> 
<assemblyIdentity name="System.Web.WebPages" publicKeyToken="31bf3856ad364e35" /> 
<bindingRedirect oldVersion="1.0.0.0-2.0.0.0" newVersion="2.0.0.0" /> 
</dependentAssembly> 
<dependentAssembly> 
<assemblyIdentity name="EntityFramework" publicKeyToken="b77a5c561934e089" culture="neutral" /> 
<bindingRedirect oldVersion="0.0.0.0-4.4.0.0" newVersion="4.4.0.0" /> 
</dependentAssembly> 
</assemblyBinding> 
</runtime> 
<entityFramework> 
<defaultConnectionFactory type="System.Data.Entity.Infrastructure.LocalDbConnectionFactory, EntityFramework"> 
<parameters> 
<parameter value="v11.0" /> 
</parameters> 
</defaultConnectionFactory> 
</entityFramework> 
</configuration> 

------ 
This the source code used in the example. 

Thks, 
Paulo
[10 Apr 2013 3:31] Paulo Finamori
TesteEF5-Migration.zip (part 1)

Attachment: TesteEF5-Migration.zip (application/octet-stream, text), 2.71 MiB.

[10 Apr 2013 17:11] Gabriela Martinez Sanchez
Paulo:

We had a problem with the .net 4.0 and 4.5 which mixed the assemblies so this msi only has the .net 4.5 version. Are you targeting your project to use this framework version? also the EF 5 should be the assembly for 4.5.

Thanks for your feedback..
[11 Apr 2013 0:07] Paulo Finamori
Is there an estimated development to solve this problem in this version? This is a system requirement, and I can't change! Thanks a lot.
[11 Apr 2013 17:14] Gabriela Martinez Sanchez
Hi Paul,

We have just released the alpha 1 version which includes the fix for this issue. Could you please try and see if this one solves it?

Here's the link http://dev.mysql.com/downloads/connector/net/#downloads then you have to pick the Development Releases.

Looking forward to your feedback.
[11 Apr 2013 22:16] Paulo Finamori
Hi Grabriela,

I updated the assemblies for 6.7.1 version, and still same problem!
Did you test with my example?
 
Thks, i look forward to your reply.
Paulo.
[12 Apr 2013 6:22] Gabriela Martinez Sanchez
Thanks for your quick response Paulo.. I'm trying to reproduce the issue. Will tell you my results ASAP.
[12 Apr 2013 13:22] Paulo Finamori
Ok Gabriela,
Thank you for your answer and attention in this issue.

Paulo.
[12 Apr 2013 13:26] Paulo Finamori
Gabriela,

If there is anything I can help you, you can count on me!

Paulo.
[12 Apr 2013 15:50] Gabriela Martinez Sanchez
Hi Paulo.. 

I have tried to reproduced although I got a different error.. I think is a matter of configuration.. even though it should have worked, so definately there is still an assembly linking problem/bug. I will personally be working on this and we'll be expecting this to be fixed on version 7.6.2 ASAP.. 

As a suggestion if you want to use migrations and EF you can used Connector/Net 6.5.6 with EF 4.3.1 and .Net 4.0

Will keep you posted.
Thanks and sorry for the inconvenience.
[12 Apr 2013 16:21] Paulo Finamori
Hi Gabriela,

Okay, i understand!So, I'm waiting for the version 6.7.2.

Thanks.
[21 May 2013 15:33] Gabriela Martinez Sanchez
A fix for this bug has been committed and fixed in the 6.7.2 release. Available to download at http://dev.mysql.com/downloads/connector/net/#downloads.
[28 Jun 2013 5:10] Philip Olson
Fixed as of the Connector/Net 6.7.2 release, and here's the changelog entry:

The Migration functionality failed when using Entity Framework 5.0 with
Connector/Net 6.7.

Thank you for the bug report.