Warning: file_get_contents(/data/phpspider/zhask/data//catemap/2/csharp/296.json): failed to open stream: No such file or directory in /data/phpspider/zhask/libs/function.php on line 167

Warning: Invalid argument supplied for foreach() in /data/phpspider/zhask/libs/tag.function.php on line 1116

Notice: Undefined index: in /data/phpspider/zhask/libs/function.php on line 180

Warning: array_chunk() expects parameter 1 to be array, null given in /data/phpspider/zhask/libs/function.php on line 181
C# EntityType没有定义键。定义此EntityType的键_C#_Entity Framework_Wcf - Fatal编程技术网

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

C# EntityType没有定义键。定义此EntityType的键,c#,entity-framework,wcf,C#,Entity Framework,Wcf,我有一个简单的WCF服务项目,其中添加了实体框架。正如您所看到的,Entity类看起来很好。然而,当我运行该项目时,我会遇到奇怪的异常EntityType'AccountOperationEntity'没有定义键。定义此EntityType的键。我以前在EF中从未遇到过类似的问题。有人能解释一下发生了什么事吗?我创建的所有类都会出现此异常 public class AccountOperationEntity { [Key] public uint Id { get; set;

我有一个简单的WCF服务项目,其中添加了实体框架。正如您所看到的,Entity类看起来很好。然而,当我运行该项目时,我会遇到奇怪的异常
EntityType'AccountOperationEntity'没有定义键。定义此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; }
}

当我尝试
启用迁移时也会发生这种情况

只是不支持Uint作为实体框架中的键


Uint只是不支持作为实体框架中的键


@KasunjithBimal没有[Table]它不应该工作吗?@KasunjithBimal没有[Table]它不应该工作吗?谢谢,这对我来说真的很神秘。错误应该是“uint not supported”。谢谢,这对我来说真的很神秘。错误应该是“uint not supported”。