Warning: file_get_contents(/data/phpspider/zhask/data//catemap/9/csharp-4.0/2.json): failed to open stream: No such file or directory in /data/phpspider/zhask/libs/function.php on line 167

Warning: Invalid argument supplied for foreach() in /data/phpspider/zhask/libs/tag.function.php on line 1116

Notice: Undefined index: in /data/phpspider/zhask/libs/function.php on line 180

Warning: array_chunk() expects parameter 1 to be array, null given in /data/phpspider/zhask/libs/function.php on line 181
Asp.net mvc 3 在ef 4.3中插入键后不显示_Asp.net Mvc 3_C# 4.0_Asp.net Mvc 4_Dbcontext - Fatal编程技术网

Asp.net mvc 3 在ef 4.3中插入键后不显示

Asp.net mvc 3 在ef 4.3中插入键后不显示,asp.net-mvc-3,c#-4.0,asp.net-mvc-4,dbcontext,Asp.net Mvc 3,C# 4.0,Asp.net Mvc 4,Dbcontext,所以我在这里读到,如果你这样做: var entity = new Entity_Table { item1 = val1, item2 = val2 }; dbcontext.Entity_Tables.Add(entity); dbcontext.SaveChanges(); int newPK = entity.ID; 您可以获取插入行的标识。但是,entity.ID不会出现在我的场景IO中 My sceneario: 1. I build the database with a

所以我在这里读到,如果你这样做:

var entity = new Entity_Table { item1 = val1, item2 = val2 }; 
dbcontext.Entity_Tables.Add(entity); 
dbcontext.SaveChanges(); 
int newPK = entity.ID;
您可以获取插入行的标识。但是,entity.ID不会出现在我的场景IO中

My sceneario: 1. I build the database with a sql script 2. Then I read it as a edmx file 3. Then I ADO.NET DbContext Generator which creates NameOfMyEntity.Context.tt and NameOfMyEntity.tt 我可以成功插入、更新和删除。但我看不到实体ID。我在运行时或编译时没有收到错误@ 请帮忙

它不再是实体.Id
只是实体。你给你的PrimaryKey取什么名字是正确的,在你读到的文章中,ID恰好是他们给他们的key取的名字。我强烈建议其他人不要使用ID来代替CustomerId、OrderId等,即使在customer/order表本身上也是如此。