I am using EF5 and Code First to create database. When Entity has Id field, EF create such field as Primary Key in database and set Identity specification to true(auto generated value). How to set Identity specification to false by default?
I am using EF5 and Code First to create database. When Entity has Id
Share
If you don’t want to use identity keys you have several options.
Option 1: You can globally turn off this feature by removing
StoreGeneratedIdentityKeyConvention:You can selectively select keys and change the behavior for them by either applying attribute or fluent mapping.
Option 2: Attribute:
Option 3: Fluent API: