I forced to work with database where tables haven't auto increment. And I can't alter it. I want to insert entity using Entity Framework. I create an object of this entity and manually set it's Id field (primay key) and then make Add and SaveChanges. But I see in log, that EF clear the value of DbParameter for Id field. Is there any solution for this?
Asked
Active
Viewed 2,789 times
1 Answers
0
You can add an annotation of fluent configuration to tell EF the keys are manual. See Entering keys manually with Entity Framework. You could also add a custom convention to handle globally: Convention for DatabaseGeneratedOption.None

Community
- 1
- 1

Steve Greene
- 12,029
- 1
- 33
- 54
-
That's exactly I sought for. Thank you, Steve! – Anton Pavelyev Mar 04 '15 at 21:17