Identity columns with ADO.NET Entity Framework

.net entity-framework identity sql-server

Question

Are identity columns recognized by the Entity Framework?

I have numerous tables where the primary key is an identity field and I am using SQL Server 2005 Express Edition. I am prompted to input a value for the identity column when I use these tables to generate an entity model and use the model in combination with an entity datasource linked to a formview to create a new entity. Is it possible to prevent the framework from requesting values for identification columns?

1
50
12/21/2011 3:02:41 PM

Popular Answer

Although this article is rather old, it could still be useful to the next person who finds it by searching for "Entitiy Framework" and "Identity" on Google.

As would be the case if the "Identity" field is set, Entity Frameworks seems to respect server-generated primary keys. However, the application side model continues to need for the provision of a primary key in theCreateYourEntityHere method. The key listed here is thrown away after theSaveChanges() to the context call

The page here has all the information in-depth about this.

67
9/19/2018 5:45:51 PM


Related Questions





Related

Licensed under: CC-BY-SA with attribution
Not affiliated with Stack Overflow
Licensed under: CC-BY-SA with attribution
Not affiliated with Stack Overflow