简体   繁体   English

在实体框架中创建方法

[英]Create Method in Entity Framework

Why does entity framework generate Create method for entities that takes parameter for the column that is defined as an identity in database? 为什么实体框架会为实体生成Create方法,该方法需要为定义为数据库中身份的列使用参数? It makes Create method totally useless as it cannot be used to create entity or am I missing something? 它使Create方法完全无用,因为它不能用于创建实体,或者我遗漏了什么?

You should set StoreGeneratedPattern as Identity on the property tab of your entity primary key property. 您应该在实体主键属性的属性选项卡上将StoreGeneratedPattern设置为Identity

Source : http://msdn.microsoft.com/en-us/library/dd283139.aspx (chapter Entity Keys and Added Objects ) 来源: http : //msdn.microsoft.com/zh-cn/library/dd283139.aspx (章节实体键和添加的对象

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM