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表本身上也是如此。