Entity Framework Code First与MySql出错

3
以下错误在 Entity Framework 4.3 及以上版本中发生:

http://www.cnblogs.com/shouzheng/archive/2012/03/09/2388177.html


(翻译) 使用EntityFramework进行代码优先开发及MySql数据库问题的解决方案案例

我希望使用最新版本的EF,因为迁移功能在版本<=4.1中不可用。

MySql.Data.MySqlClient.MySqlException (0x80004005):您的SQL语法存在错误;请检查与您的MySQL服务器版本相对应的手册,以获取正确的语法。在第6行附近出现了“NOT NULL”,ProductVersion mediumtext NOT NULL的使用方法不正确。 在MySql.Data.MySqlClient.MySqlStream.ReadPacket()中 在MySql.Data.MySqlClient.NativeDriver.GetResult(Int32& affectedRow, Int32& insertedId)中 在MySql.Data.MySqlClient.Driver.GetResult(Int32 statementId, Int32& affectedRows, Int32& insertedId)中 在MySql.Data.MySqlClient.Driver.NextResult(Int32 statementId, Boolean force)中 在MySql.Data.MySqlClient.MySqlDataReader.NextResult()中 在MySql.Data.MySqlClient.MySqlCommand.ExecuteReader(CommandBehavior behavior)中 在MySql.Data.MySqlClient.MySqlCommand.ExecuteNonQuery()中 在System.Data.Objects.ObjectContext.ExecuteStoreCommand(String commandText, Object[] parameters)中 在System.Data.Entity.Internal.InternalContext.ExecuteSqlCommand(String sql, Object[] parameters)中 在System.Data.Entity.Database.ExecuteSqlCommand(String sql, Object[] parameters)中 在System.Data.Entity.Migrations.History.HistoryRepository.BootstrapUsingEFProviderDdl(XDocument model)中 在System.Data.Entity.Internal.InternalContext.<SaveMetadataToDatabase>b__4()中 在System.Data.Entity.Internal.InternalContext.PerformInitializationAction(Action action)中 在System.Data.Entity.Internal.InternalContext.SaveMetadataToDatabase()中 在System.Data.Entity.Internal.DatabaseCreator.CreateDatabase(InternalContext internalContext, Func3 createMigrator, ObjectContext objectContext)中 在System.Data.Entity.Internal.InternalContext.CreateDatabase(ObjectContext objectContext)中 在System.Data.Entity.Database.Create()中 在System.Data.Entity.DropCreateDatabaseAlways1.InitializeDatabase(TContext context)中 在System.Data.Entity.Database.<>c__DisplayClass21.b_0(DbContext c)中 在System.Data.Entity.Internal.InternalContext.<>c_DisplayClass8.b_6()中 在System.Data.Entity.Internal.InternalContext.PerformInitializationAction(Action action)中 在System.Data.Entity.Internal.InternalContext.PerformDatabaseInitialization()中 在System.Data.Entity.Internal.LazyInternalContext.b_4(InternalContext c)中 在System.Data.Entity.Internal.RetryAction1.PerformAction(TInput input)中 在System.Data.Entity.Internal.LazyInternalContext.InitializeDatabaseAction(Action1 action)中 在System.Data.Entity.Internal.LazyInternalContext.InitializeDatabase()中 在System.Data.Entity.Internal.InternalContext.GetEntitySetAndBaseTypeForType(Type entityType)中 在System.Data.Entity.Internal.Linq.InternalSet1.Initialize()中 在System.Data.Entity.Internal.Linq.InternalSet1.get_InternalContext()中 在System.Data.Entity.Internal.Linq.InternalSet1.ActOnSet(Action action, EntityState newState, Object entity, String methodName)中 在System.Data.Entity.Internal.Linq.InternalSet1.Add(Object entity)中 在System.Data.Entity.DbSet`1.Add(TEntity entity)中 在DBPreparationTool.Form1.PrepareDB_Click(Object sender, EventArgs e)中,位于D:\Workspaces\Experiments\FaizeMBRoot\Source\DBPreparationTool\Form1.cs的第39行。在System.Windows.Forms.Control.OnClick(EventArgs e)中 在System.Windows.Forms.Button.OnClick(EventArgs e)中 在System.Windows.Forms.ButtonBase.OnKeyUp(KeyEventArgs kevent)中 在System.Windows.Forms.Control.ProcessKeyEventArgs(Message& m)中 在System.Windows.Forms.Control.ProcessKeyMessage(Message& m)中 在System.Windows.Forms.Control.WndProc(Message& m)中 在System.Windows.Forms.ButtonBase.WndProc(Message& m)中 在System.Windows.Forms.Button.WndProc(Message& m)中 在System.Windows.Forms.Control.ControlNativeWindow.OnMessage(Message& m)中 在System.Windows.Forms.Control.ControlNativeWindow.WndProc(Message& m)中 在System.Windows.Forms.NativeWindow.Callback(IntPtr hWnd, Int32 msg, IntPtr wparam, IntPtr lparam)中。

有没有办法克服这个错误并继续前进? - IsmailS
抱歉,链接错误。现在已经指向正确的地址了。 - IsmailS
1个回答

4

网页内容由stack overflow 提供, 点击上面的
可以查看英文原文,
原文链接