Bug #61918 Entity Framework: Cascading insert is failing
Submitted: 19 Jul 2011 19:49 Modified: 4 Aug 2011 17:00
Reporter: Matt Houser Email Updates:
Status: Not a Bug Impact on me:
Category:Connector / NET Severity:S1 (Critical)
Version:6.4.3 OS:Any
Assigned to: Julio Casal CPU Architecture:Any

[19 Jul 2011 19:49] Matt Houser
Inserting into 2 tables where one is a foreign key to another is failing.

How to repeat:
Sample project and model will be attached.

Suggested fix:
Inserts should succeed.
[19 Jul 2011 19:50] Matt Houser
Sample application and database model

Attachment: Problem.zip (application/x-zip-compressed, text), 146.70 KiB.

[4 Aug 2011 17:00] Julio Casal
Thank you for taking the time to write to us, but this is not a bug. Please double-check the documentation available at http://dev.mysql.com/doc/ and the instructions on how to report a bug at http://bugs.mysql.com/how-to-report.php

In your sample application SaveChanges fails because you are not specifying an id for the Log entity. Given that Log.LogId is autogenerated in the database you should set StoreGeneratedPattern = Identity so that the model gets updated with the new db generated id. That will fix the foreign key issue. 

You will need to remove and regenerate the Log entity for your model to get StoreGeneratedPattern = Identity in Log.LogId.