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时。

+0

@KasunjithBimal不应该没有[表]工作? – lll

Uint只是不支持在实体框架中的关键。

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

+0

谢谢,这对我来说真的很神秘。该错误应该说“不支持的uint”。 – lll