实体框架代码首先出现MySql错误

时间:2012-05-05 18:12:51

标签: mysql entity-framework-4.3 entity-framework-5

实体框架版本4.3 +

发生以下错误

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

(翻译)Use EntityFramework the Code First Development and one case of MySql database problem

我想使用最新版本的EF,因为迁移功能不适用于版本< = 4.1。

  

MySql.Data.MySqlClient.MySqlException(0x80004005):您有错误   在你的SQL语法中;查看与MySQL对应的手册   在'NOT NULL附近使用正确语法的服务器版本,     ProductVersion mediumtext NOT NULL);

     

ALTER TABLE __MigrationH' at line 6 at MySql.Data.MySqlClient.MySqlStream.ReadPacket() at MySql.Data.MySqlClient.NativeDriver.GetResult(Int32& affectedRow, Int32& insertedId) at MySql.Data.MySqlClient.Driver.GetResult(Int32 statementId, Int32& affectedRows, Int32& insertedId) at MySql.Data.MySqlClient.Driver.NextResult(Int32 statementId, Boolean force) at MySql.Data.MySqlClient.MySqlDataReader.NextResult() at MySql.Data.MySqlClient.MySqlCommand.ExecuteReader(CommandBehavior behavior) at MySql.Data.MySqlClient.MySqlCommand.ExecuteNonQuery() at System.Data.Objects.ObjectContext.ExecuteStoreCommand(String commandText, Object[] parameters) at System.Data.Entity.Internal.InternalContext.ExecuteSqlCommand(String sql, Object[] parameters) at System.Data.Entity.Database.ExecuteSqlCommand(String sql, Object[] parameters) at System.Data.Entity.Migrations.History.HistoryRepository.BootstrapUsingEFProviderDdl(XDocument model) at System.Data.Entity.Internal.InternalContext.<SaveMetadataToDatabase>b__4() at System.Data.Entity.Internal.InternalContext.PerformInitializationAction(Action action) at System.Data.Entity.Internal.InternalContext.SaveMetadataToDatabase()
at System.Data.Entity.Internal.DatabaseCreator.CreateDatabase(InternalContext internalContext, Func
3 createMigrator,ObjectContext objectContext)
  在   System.Data.Entity.Internal.InternalContext.CreateDatabase(ObjectContext的   objectContext)在System.Data.Entity.Database.Create()at   System.Data.Entity.DropCreateDatabaseAlways 1.InitializeDatabase(TContext context) at System.Data.Entity.Database.<>c__DisplayClass2 1.b_ 0(的DbContext   猫   System.Data.Entity.Internal.InternalContext&LT;。&以及c _DisplayClass8.b_ 6()   在   System.Data.Entity.Internal.InternalContext.PerformInitializationAction(动作   行动)   System.Data.Entity.Internal.InternalContext.PerformDatabaseInitialization()   在   System.Data.Entity.Internal.LazyInternalContext.b _4(InternalContext   猫   System.Data.Entity.Internal.RetryAction 1.PerformAction(TInput input) at System.Data.Entity.Internal.LazyInternalContext.InitializeDatabaseAction(Action 1   行动)   System.Data.Entity.Internal.LazyInternalContext.InitializeDatabase()
  在   System.Data.Entity.Internal.InternalContext.GetEntitySetAndBaseTypeForType(类型   entityType)at   System.Data.Entity.Internal.Linq.InternalSet 1.Initialize() at System.Data.Entity.Internal.Linq.InternalSet 1.get_InternalContext()
  at System.Data.Entity.Internal.Linq.InternalSet 1.ActOnSet(Action action, EntityState newState, Object entity, String methodName) at System.Data.Entity.Internal.Linq.InternalSet 1.Add(Object entity)
  在System.Data.Entity.DbSet`1.Add(TEntity实体)at   DBPreparationTool.Form1.PrepareDB_Click(Object sender,EventArgs e)in   d:\工作区\实验\ FaizeMBRoot \来源\ DBPreparationTool \ Form1.cs中:行   39在System.Windows.Forms.Control.OnClick(EventArgs e)at   System.Windows.Forms.Button.OnClick(EventArgs e)at   System.Windows.Forms.ButtonBase.OnKeyUp(KeyEventArgs kevent)at   System.Windows.Forms.Control.ProcessKeyEventArgs(Message&amp; m)at   System.Windows.Forms.Control.ProcessKeyMessage(Message&amp; m)at   System.Windows.Forms.Control.WndProc(Message&amp; m)at   System.Windows.Forms.ButtonBase.WndProc(Message&amp; m)at   System.Windows.Forms.Button.WndProc(Message&amp; m)at   System.Windows.Forms.Control.ControlNativeWindow.OnMessage(Message&amp; m)   在System.Windows.Forms.Control.ControlNativeWindow.WndProc(Message&amp;   m)在System.Windows.Forms.NativeWindow.Callback(IntPtr hWnd,Int32)   msg,IntPtr wparam,IntPtr lparam)

1 个答案:

答案 0 :(得分:4)