EntityType没有定义密钥。定义这个实体类型的关键
问题描述:
我有一个简单的WCF服务项目,我已经添加了实体框架。正如你所看到的,Entity类很好看。然而,当我运行该项目时,我得到了奇怪的异常EntityType 'AccountOperationEntity' has no key defined. Define the key for this EntityType.
我从来没有像EF这样的问题。有人能解释我发生了什么事吗?我创建的所有课程都会得到这个例外。EntityType没有定义密钥。定义这个实体类型的关键
public class AccountOperationEntity
{
[Key]
public uint Id { get; set; }
public virtual AccountEntity Account { get; set; }
public OperationType OperationType { get; set; }
public float Amount { get; set; }
public DateTime DateTime { get; set; }
}
这也发生在我尝试enable-migrations
时。
@KasunjithBimal不应该没有[表]工作? – lll