The project has the use of MySQL database, EF Do data layer, found that there is a table saved always error. The error message is as follows
System.NullReferenceException: Object reference not set to an instance of an object.
In MYSQL.DATA.ENTITY.LISTFRAGMENT.WRITESQL (StringBuilder sql)
In MYSQL.DATA.ENTITY.SELECTSTATEMENT.WRITESQL (StringBuilder sql)
In MYSQL.DATA.ENTITY.INSERTSTATEMENT.WRITESQL (StringBuilder sql)
In MySql.Data.Entity.SqlFragment.ToString ()
In MySql.Data.Entity.InsertGenerator.GenerateSQL (Dbcommandtree tree)
In MySql.Data.MySqlClient.MySqlProviderServices.CreateDbCommandDefinition (Dbprovidermanifest providermanifest, Dbcommandtree Commandtree)
In System.Data.Common.DbProviderServices.CreateCommandDefinition (Dbcommandtree commandtree)
In System.Data.Common.DbProviderServices.CreateCommand (Dbcommandtree commandtree)
In System.Data.Mapping.Update.Internal.UpdateTranslator.CreateCommand (Dbmodificationcommandtree commandtree)
In System.Data.Mapping.Update.Internal.DynamicUpdateCommand.CreateCommand (updatetranslator translator, Dictionary ' 2 identifiervalues)
In System.Data.Mapping.Update.Internal.DynamicUpdateCommand.Execute (updatetranslator translator, EntityConnection Connection, Dictionary ' 2identifiervalues,list ' 1 generatedvalues)
In System.Data.Mapping.Update.Internal.UpdateTranslator.Update (Ientitystatemanager Statemanager, Ientityadapter Adapter
In System.Data.EntityClient.EntityAdapter.Update (Ientitystatemanager entitycache)
In System.Data.Objects.ObjectContext.SaveChanges (saveoptions options)
In System.Data.Entity.Internal.InternalContext.SaveChanges ()
In System.Data.Entity.Internal.LazyInternalContext.SaveChanges ()
In System.Data.Entity.DbContext.SaveChanges ()
Later on StackOverflow, I was prompted to find out that the problem with this version of MySQL Connector. Net 6.6.5 is that, in this release, if the primary key in the table is self-growing, when the type of the column is tinyint, Utinyint, Ubigint, The above error will occur. But no solution was available.
But not too much panic, in the previous version did not find this problem, and then went to the official website to see a bit, the latest MySQL Connector. NET is already a 6.9.5, and has not been tested for this problem.
MYSQL to EF in savechange times null reference error