7
在實體框架4.3.1,我有以下型號,它們工作得很好:實體框架4.3.1 - > 5.0例外:「EntityType沒有定義密鑰,請爲此EntityType定義密鑰。」
public class BaseUser
{
[Key]
[MaxLength(100)]
public string Username { get; set; }
}
[Table("AppUser")] // Ensures EF Code First uses Table-per-Type
public class AppUser : BaseUser
{
[MaxLength(200)]
public string About { get; set; }
}
升級到EF 5.0,我得到下面的異常,當我嘗試運行該應用程序並訪問相關的DbContext後:
EntityType 'AppUser' has no key defined. Define the key for this EntityType.
如何解決此問題?這似乎是一種迴歸。