Asp.net mvc 4 在EF CodeFirst中使用复杂数据类型
这是我的模型:Asp.net mvc 4 在EF CodeFirst中使用复杂数据类型,asp.net-mvc-4,ef-code-first,entity-framework-5,Asp.net Mvc 4,Ef Code First,Entity Framework 5,这是我的模型: public class Course { public int Id { get; set; } public string Title { get; set; } public string Institute { get; set; } public string Instructor { get; set; } public string Duration { get; set; }
public class Course
{
public int Id { get; set; }
public string Title { get; set; }
public string Institute { get; set; }
public string Instructor { get; set; }
public string Duration { get; set; }
public Level Level { get; set; }
public Format Format { get; set; }
public DateTime Released { get; set; }
public string FileSize { get; set; }
public string Desciption { get; set; }
}
public enum Level
{
Beginner,
Intermediate,
Advanced
}
public enum Format
{
Avi,
Hd,
FullHd
}
public class CourseDb:DbContext
{
public DbSet<Course> Courses { get; set; }
}
公共课
{
公共int Id{get;set;}
公共字符串标题{get;set;}
公共字符串机构{get;set;}
公共字符串指导员{get;set;}
公共字符串持续时间{get;set;}
公共级别{get;set;}
公共格式{get;set;}
发布的公共日期时间{get;set;}
公共字符串文件大小{get;set;}
公共字符串说明{get;set;}
}
公共枚举级别
{
初学者,
中间的
先进的
}
公共枚举格式
{
阿维,
房屋署,
全高清
}
公共课程B:DbContext
{
公共数据库集课程{get;set;}
}
当我想使用EF模板创建带有支架的新控制器时,当我使用EF5时,不能同时创建
级别
和格式
字段我有什么问题?
感谢您的建议搭建时当前不支持枚举类型,这很可能是未创建字段的原因 我的建议是使用助手方法,例如: 并手动编写代码 更新: 这里似乎记录了支持它的票证: