I need to mirate my dbContext class , but I got this error :
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. here is my DbContext :
namespace seraydar.Models { public class Context : DbContext { public DbSet<UserType> UserTypes { get; set; } } } and here is my class:
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; } } I just got confused!