C# ASP.Net MVC 5 MF未创建枚举列

C# ASP.Net MVC 5 MF未创建枚举列,c#,asp.net,asp.net-mvc,entity-framework,ef-code-first,C#,Asp.net,Asp.net Mvc,Entity Framework,Ef Code First,我是ASP.Net新手,我正在尝试开发一个表示系统日志的模型,但是控制器向导(创建脚手架视图)和代码优先方法并没有创建所有列 这是我的模型的定义: namespace Project.Models { public enum SystemComponents : byte { Component1, Component2, Component3 } public enum LogMessageCategory : byte {

我是ASP.Net新手,我正在尝试开发一个表示系统日志的模型,但是控制器向导(创建脚手架视图)和代码优先方法并没有创建所有列

这是我的模型的定义:

namespace Project.Models
{
    public enum SystemComponents : byte
    {
        Component1, Component2, Component3
    }

    public enum LogMessageCategory : byte
    {
        Warning, Error, Debug, Log
    }

    public class LogDbContext : DbContext
    {
        public DbSet<Log> Logs { get; set; }
    }

    public class Log
    {
        public int ID { get; set; }

        [Required]
        public SystemComponents AffectedComponent;

        [Required]
        public LogMessageCategory MessageCategory;

        [Display(ResourceType = typeof(Resources.Resources), Name = "EventDate")]
        [DataType(DataType.Date)]
        [DisplayFormat(DataFormatString = "{0:yyyy-MM-dd}", ApplyFormatInEditMode = true)]
        [Required]
        public DateTime EventDate { get; set; }

        /// <summary>
        /// Foreign Key that represents the event's emisor.
        /// This can be both a User, or a System component
        /// </summary>
        public int ActorID { get; set; }

        /// <summary>
        /// Foreign Key that represents the event's emisor.
        /// This can be both a User, or a System component
        /// </summary>
        public int ComponentID { get; set; }
}
namespace项目.模型
{
公共枚举系统组件:字节
{
组件1、组件2、组件3
}
公共枚举LogMessageCategory:字节
{
警告、错误、调试、日志
}
公共类LogDbContext:DbContext
{
公共数据库集日志{get;set;}
}
公共类日志
{
公共int ID{get;set;}
[必需]
公共系统组件影响组件;
[必需]
公共日志消息类别消息类别;
[显示(ResourceType=typeof(Resources.Resources),Name=“EventDate”)]
[数据类型(DataType.Date)]
[DisplayFormat(DataFormatString=“{0:yyyy-MM-dd}”,ApplyFormatInEditMode=true)]
[必需]
公共日期时间事件日期{get;set;}
/// 
///表示事件的发射器的外键。
///这可以是用户,也可以是系统组件
/// 
公共int ActorID{get;set;}
/// 
///表示事件的发射器的外键。
///这可以是用户,也可以是系统组件
/// 
公共int组件ID{get;set;}
}
我做错了什么?另外,在使用资源(用于国际化)的视图中显示此属性的正确方法是什么?(由于此模型的实例将由系统创建,我不关心如何在创建视图中显示字段)

另外,还有一个问题,我是否必须声明我的所有属性才能使用它们?在线教程没有解释这一点,但如果没有,则不会在数据库中创建字段


p.D.我想我使用的是EF 6.0(VS 2013 Premium)

您可能只需要将它们作为属性公开,而不是公开字段

[Required]
public SystemComponents AffectedComponent{ get; set; }

[Required]
public LogMessageCategory MessageCategory{ get; set; }