【问题标题】:Using Complex DataType in EF CodeFirst首先在 EF 代码中使用复杂数据类型
【发布时间】:2013-02-15 16:22:13
【问题描述】:

这是我的模特:

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; }
    }

当我想使用 EF 模板创建我的新控制器时,
在我使用 EF5 时,它不会同时创建 LevelFormat 字段
我的问题是什么?
谢谢你的建议

【问题讨论】:

    标签: asp.net-mvc-4 ef-code-first entity-framework-5


    【解决方案1】:

    目前在脚手架时不支持枚举类型,这很可能是未创建字段的原因。

    我的建议是使用辅助方法,例如:Working with enums in ASP.NET MVC 3

    并手动编码。

    更新:

    看起来这里已经记录了支持它的票:http://mvcscaffolding.codeplex.com/workitem/10

    【讨论】:

      猜你喜欢
      • 1970-01-01
      • 2013-05-21
      • 1970-01-01
      • 1970-01-01
      • 2012-01-26
      • 2020-04-07
      • 2012-11-25
      • 1970-01-01
      相关资源
      最近更新 更多