繁体   English   中英

EntityType没有定义键。 定义此EntityType的键

[英]EntityType has no key defined. Define the key for this EntityType

我有一个简单的WCF服务项目,已在其中添加了Entity Framework。 如您所见,Entity类看起来不错。 但是,当我运行项目时,出现奇怪的异常EntityType 'AccountOperationEntity' has no key defined. Define the key for this EntityType. EntityType 'AccountOperationEntity' has no key defined. Define the key for this EntityType. EF之前我从来没有遇到过这样的问题。 有人可以解释一下发生了什么吗? 我创建的所有类均出现此异常。

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时,也会发生这种情况。

只是在实体框架中不支持将Uint作为键。

https://entityframework.codeplex.com/workitem/1489

暂无
暂无

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM