SaveChanges() in Entity Framework does not retrieve the created Identity key.

.net c# entity-framework identity

Question

In my project, I'm utilizing Entity Framework, and it's been a nightmare!

I have a Form table in my SQL database.

Form has an Identity that is automatically incremented and a PK-type ID.

I'm going to do this this time:

Dim form as int32
Dim dbform As New Entities1
Dim form696 As New Form

dbform.AddToForm696(form)
dbform.SaveChanges()

ID = form.ID

ID and form were last week. Prior to insert, ID had the key produced, however it now just contains 0.

I'm not sure what occurred to cause this to cease functioning.

I had to redo the mapping since I had to modify the names of multiple tables' insert, remove, and update stored procedures. Maybe I made a mistake, but every time I checked, everything seemed to be in order.

Does anybody know the reason?

1
3
12/21/2011 3:03:32 PM

Accepted Answer

Patches, in my opinion, have taken care of this problem. If your Data Model is still not functioning, you could try removing it and adding it again. EF seems to be dealing with this less currently.

3
2/15/2010 7:10:09 PM

Popular Answer

Okay, I completely missed this.

http://blogs.microsoft.co.il/blogs/bursteg/archive/2007/12/17/ado-net-entity-framework-tools-stored-procedures.aspx

I had to "assign the new value to an entity column using the Result Column Binding."

Why not have Entity Fw do it for me?



Related Questions





Related

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