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
?
相关问题
- Entity Framework Code First Migration
- Entity Framework throws exception - Network Relate
- Slow loading first page - ASP.NET MVC
- query and create objects with a one to many relati
- Entity Framework override default property convent
相关文章
-
EF6 DbSet
returns null in Moq - Entity Framework 4.3.1 failing to create (/open) a
- EF6 code first: How to load DbCompiledModel from E
- Why do I need a ToList() to avoid disposed context
- Code-First Add-Migration keeps adding the same col
- EF Codefirst validate unique property?
- EF Core 'another instance is already being tra
- Add XML documentation / comments to properties/fie
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: