实体框架代码首先出现MySql错误
作者:互联网
实体框架版本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): You have an error
in your SQL syntax; check the manual that corresponds to your MySQL
server version for the right syntax to use near ‘NOT NULL,
ProductVersion
mediumtext NOT NULL);ALTER TABLE
__MigrationH' at line 6 at
3 createMigrator, ObjectContext objectContext)
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
at
System.Data.Entity.Internal.InternalContext.CreateDatabase(ObjectContext
objectContext) at System.Data.Entity.Database.Create() at
System.Data.Entity.DropCreateDatabaseAlways1.InitializeDatabase(TContext
1.b_0(DbContext
context) at
System.Data.Entity.Database.<>c__DisplayClass2
c) at
System.Data.Entity.Internal.InternalContext.<>c_DisplayClass8.b_6()
at
System.Data.Entity.Internal.InternalContext.PerformInitializationAction(Action
action) at
System.Data.Entity.Internal.InternalContext.PerformDatabaseInitialization()
at
System.Data.Entity.Internal.LazyInternalContext.b_4(InternalContext
c) at
System.Data.Entity.Internal.RetryAction1.PerformAction(TInput input)
1
at
System.Data.Entity.Internal.LazyInternalContext.InitializeDatabaseAction(Action
action) at
System.Data.Entity.Internal.LazyInternalContext.InitializeDatabase()
at
System.Data.Entity.Internal.InternalContext.GetEntitySetAndBaseTypeForType(Type
entityType) at
System.Data.Entity.Internal.Linq.InternalSet1.Initialize() at
1.get_InternalContext()
System.Data.Entity.Internal.Linq.InternalSet
at System.Data.Entity.Internal.Linq.InternalSet1.ActOnSet(Action
1.Add(Object entity)
action, EntityState newState, Object entity, String methodName) at
System.Data.Entity.Internal.Linq.InternalSet
at System.Data.Entity.DbSet`1.Add(TEntity entity) at
DBPreparationTool.Form1.PrepareDB_Click(Object sender, EventArgs e) in
D:\Workspaces\Experiments\FaizeMBRoot\Source\DBPreparationTool\Form1.cs:line
39 at 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& m) at
System.Windows.Forms.Control.ProcessKeyMessage(Message& m) at
System.Windows.Forms.Control.WndProc(Message& m) at
System.Windows.Forms.ButtonBase.WndProc(Message& m) at
System.Windows.Forms.Button.WndProc(Message& m) at
System.Windows.Forms.Control.ControlNativeWindow.OnMessage(Message& m)
at System.Windows.Forms.Control.ControlNativeWindow.WndProc(Message&
m) at System.Windows.Forms.NativeWindow.Callback(IntPtr hWnd, Int32
msg, IntPtr wparam, IntPtr lparam)
解决方法:
看到这个博客文章:http://brice-lambson.blogspot.com/2012/05/using-entity-framework-code-first-with.html
标签:entity-framework-4-3,entity-framework-5,mysql 来源: https://codeday.me/bug/20191101/1983092.html