MYSQL to EF in savechange times null reference error

Source: Internet
Author: User

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

Related Article

Contact Us

The content source of this page is from Internet, which doesn't represent Alibaba Cloud's opinion; products and services mentioned on that page don't have any relationship with Alibaba Cloud. If the content of the page makes you feel confusing, please write us an email, we will handle the problem within 5 days after receiving your email.

If you find any instances of plagiarism from the community, please send an email to: info-contact@alibabacloud.com and provide relevant evidence. A staff member will contact you within 5 working days.

A Free Trial That Lets You Build Big!

Start building with 50+ products and up to 12 months usage for Elastic Compute Service

  • Sales Support

    1 on 1 presale consultation

  • After-Sales Support

    24/7 Technical Support 6 Free Tickets per Quarter Faster Response

  • Alibaba Cloud offers highly flexible support services tailored to meet your exact needs.