我使用EF5和.NET 4.5。 我有一個特定的類在數據庫中被錯誤地生成。 雖然在我的網站上有點複雜,但我會簡化一下;ef 5數據庫中沒有生成codefirst枚舉集合
namespace Store.Enities
{
public enum Role
{ Manager, Clerk }
public class User
{
public int Id {get; set;}
public ICollection<Role> Roles {get; set;}
}
public class StoreContext : DbContext
{
public DbSet<User> Users {get; set;}
public StoreContext()
{
Database.SetIntializer(new DropCreateDatabaseIfModelChanges<StoreContext>());
}
}
}
正如您所看到的,用戶可以擁有多個角色。 出於某種原因,我無法將角色存儲在數據庫中。