Reputation: 163
I'm using the code-first approach and because of that I do not have the .edmx
file so I cannot change the StoreGeneratedPattern
attribute. How do I then make EF auto-increment the IDs? (right now all IDs are zeros by default)
Upvotes: 1
Views: 1850
Reputation: 125
There are three ways to specify keys using EF code first:
Upvotes: 1
Reputation: 3573
A primary key with auto-increment (default behavior) is generated if any of the following holds true:
Might it be that your property is named "ID" instead of "Id" without the Key attribute?
Upvotes: 1