简体   繁体   中英

EntityType has no key defined. Define the key for this EntityType

I have a simple WCF service project to which I've added Entity Framework. As you can see the Entity class looks well. However when I'm running the project, I'm getting weird exception EntityType 'AccountOperationEntity' has no key defined. Define the key for this EntityType. EntityType 'AccountOperationEntity' has no key defined. Define the key for this EntityType. I've never had problems like this before with EF. Could someone explain me what 's going on? I get this exception with all classes I create.

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; }
}

This also happens when I try to enable-migrations .

Uint is just not supported as key in Entity Framework.

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

The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.

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