EntityFramework 连接串导致的错误
默认的以"metadata=res://*/ "开头的连接串包含了对象的键信息,
View Code
1 <EntityType Name="table">
2 <Key>
3 <PropertyRef Name="UserID" />
4 </Key>
5 ...
2 <Key>
3 <PropertyRef Name="UserID" />
4 </Key>
5 ...
所以在类中不必加[Key]等属性,这种方式对于DataBase First方式显得非常重要,每次更新数据库后,类会重新生成,如果用普通的连接串则会报
System.Data.Edm.EdmEntityType: : EntityType 'table' has no key defined. Define the key for this EntityType
System.Data.Edm.EdmEntitySet: EntityType: The EntitySet table is based on type table that has no keys defined.