ADO.NET Entity Framework and identity columns

前端 未结 10 1537
甜味超标
甜味超标 2020-12-29 18:06

Is the Entity Framework aware of identity columns?

I am using SQL Server 2005 Express Edition and have several tables where the primary key is an identity column. w

10条回答
  •  我在风中等你
    2020-12-29 18:26

    I know this post is quite old, but this may help the next person arriving hear via a Google search for "Entitiy Framework" and "Identity".

    It seems that Entity Frameworks does respect server-generated primary keys, as the case would be if the "Identity" property is set. However, the application side model still requires a primary key to be supplied in the CreateYourEntityHere method. The key specified here is discarded upon the SaveChanges() call to the context.

    The page here gives the detailed information regarding this.

提交回复
热议问题