0
我需要mirate我的DbContext类,但我得到这个错误:Ef中迁移错误
System.Data.Entity.Edm.EdmEntityType: : EntityType 'UserType' has no key defined. Define the key for this EntityType.
System.Data.Entity.Edm.EdmEntitySet: EntityType: EntitySet 'UserTypes' is based on type 'UserType' that has no keys defined.
这里是我的DbContext:
namespace seraydar.Models
{
public class Context : DbContext
{
public DbSet<UserType> UserTypes { get; set; }
}
}
,这里是我的课:
public class UserType
{
[Key]
int id { get; set; }
[Required, MaxLength(30, ErrorMessage = "Name can not be longer than 30 characters."), Display(Name = "User Type")]
string userType { get; set; }
}
我只是感到困惑!
谢谢,它的工作 – 2014-08-28 06:34:55