EF6+MySQL - Error inserting 2 related objects in a single SaveChanges

entity-framework entity-framework-6 mysql


I'm trying to insert two new, connected objects—Client and Quote (where Quote has a Client)—into a single call to save changes using EF6 and MySql. This ought to correspond to both an insert into the quotation table and an insert into the client table. Coding is:

        var client = new Client();
        var quote = new Quote();
        quote.Client = client;


Except for:

Additional information: An error occurred while updating the entries. See the inner exception for details.

   at System.Data.Entity.Internal.InternalContext.SaveChanges()
   at System.Data.Entity.Internal.LazyInternalContext.SaveChanges()
   at System.Data.Entity.DbContext.SaveChanges()
  at MyTestClass... 

Within Exception is:

{"The specified value is not an instance of a valid constant type.\r\nParameter name: type"}

   at System.Data.Entity.Core.Mapping.Update.Internal.UpdateTranslator.Update()
   at System.Data.Entity.Core.EntityClient.Internal.EntityAdapter.<Update>b__2(UpdateTranslator ut)
   at System.Data.Entity.Core.EntityClient.Internal.EntityAdapter.Update[T](T noChangesResult, Func`2 updateFunction, Boolean throwOnClosedConnection)
   at System.Data.Entity.Core.EntityClient.Internal.EntityAdapter.Update(Boolean throwOnClosedConnection)
   at System.Data.Entity.Core.Objects.ObjectContext.<SaveChangesToStore>b__33()
   at System.Data.Entity.Core.Objects.ObjectContext.ExecuteInTransaction[T](Func`1 func, IDbExecutionStrategy executionStrategy, Boolean startLocalTransaction, Boolean releaseConnectionOnSuccess)
   at System.Data.Entity.Core.Objects.ObjectContext.SaveChangesToStore(SaveOptions options, IDbExecutionStrategy executionStrategy)
   at System.Data.Entity.Core.Objects.ObjectContext.<>c__DisplayClass28.<SaveChanges>b__25()
   at System.Data.Entity.Infrastructure.DefaultExecutionStrategy.Execute[TResult](Func`1 operation)
   at System.Data.Entity.Core.Objects.ObjectContext.SaveChanges(SaveOptions options)
   at System.Data.Entity.Internal.InternalContext.SaveChanges()

classifications of entities

public class Client
    public long Id { get; set; }

public class Quote

    public long Id { get; set; }

    public long ClientId { get; set; }

    public virtual Client Client { get; set; }


  • EF6
  • v6.8.3 of MySql.Data.dll
  • v6.8.3 of MySql.Data.Entity.EF6.dll

If I follow the db.Client with a call to db.SaveChanges(). It will function properly to add the "client" line, but I want to execute a SavChanges as late as feasible to group database calls. Any suggestions as to what might be wrong?

3/4/2014 6:26:36 AM

Accepted Answer

The issue was brought on by signed/unsigned bigints, as mentioned in here.

5/23/2017 10:33:22 AM

Popular Answer


Related Questions


Licensed under: CC-BY-SA with attribution
Not affiliated with Stack Overflow
Licensed under: CC-BY-SA with attribution
Not affiliated with Stack Overflow