ADO.NET实体框架和标识列 [英] ADO.NET Entity Framework and identity columns

查看:85
本文介绍了ADO.NET实体框架和标识列的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

时的实体框架知道标识列?

Is the Entity Framework aware of identity columns?

我使用SQL Server 2005的防爆preSS版,并有几个表,其中主键是标识列。当我使用这些表来创建一个实体模型,并利用该模型结合的实体数据源的债券,以一个FormView,以创建一个新的实体,我要求输入标识列的值。有没有一种方法,使框架没有要求值,标识列?

I am using SQL Server 2005 Express Edition and have several tables where the primary key is an identity column. when I use these tables to create an entity model and use the model in conjunction with an entity datasource bond to a formview in order to create a new entity I am asked to enter a value for the identity column. Is there a way to make the framework not ask for values for identity columns?

推荐答案

我知道这个职位是很老了,但是这可能有助于在未来通过谷歌搜索Entitiy框架和身份到达听到的人。

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".

看来,实体框架不尊重服务器生成的主键,视具体情况是,如果身份属性设置。但是,应用程序端模型还需要一个主键在 CreateYourEntityHere 方法来提供。这里指定的键于的SaveChanges()调用上下文丢弃。

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.

这篇关于ADO.NET实体框架和标识列的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆