【发布时间】:2015-04-22 16:32:25
【问题描述】:
我的实体框架代码优先上下文中有以下类
public class DataBinding
{
[Key]
public DataSource Source
{ get; set; }
[Key]
public DataType Type
{ get; set; }
.....
}
DataSource 和 DataType 都属于同一个上下文,但是当我尝试创建数据库时,出现以下错误 EntityType 'DataBinding' has no key defined. Define the key for this EntityType.
DataBindings: EntityType: EntitySet 'DataBindings' is based on type 'DataBinding' that has no keys defined. 我定义了两个键,为什么会出现此错误?
【问题讨论】:
标签: c# ef-code-first entity-framework-6