Asp.net mvc 4 EF 6代码首先不创建数据库

Asp.net mvc 4 EF 6代码首先不创建数据库,asp.net-mvc-4,ef-code-first,database-connection,connection-string,code-first,Asp.net Mvc 4,Ef Code First,Database Connection,Connection String,Code First,我搜索了很多解决方案,但我不明白为什么数据库不能创建?我的类和上下文类非常简单 public class News { [Key] public int NewsID { get; set; } public string NewsHeader { get; set; } public string News { get; set; } public int CategoryID; public virtual Category Category

我搜索了很多解决方案,但我不明白为什么数据库不能创建?我的类和上下文类非常简单

public class News
{
    [Key]
    public int NewsID { get; set; }
    public string NewsHeader { get; set; }
    public string News { get; set; }

    public int CategoryID;
    public virtual Category Category { get; set; }
}

public class Category 
{
    [Key]
    public int CategoryID { get; set; }
    public string CategoryName{ get; set; }

    public virtual ICollection<News> Newss { get; set; }
}

public class NewsContext: DbContext
{
     public NewsContext(): base("NewsContext") 
    {
        Database.SetInitializer<NewsContext>(new CreateDatabaseIfNotExists<NewsContext>());
    }
    public DbSet<News> Newss { get; set; }
    public DbSet<Category> Categories { get; set; }
}
我的连接字符串就在下面

 <connectionStrings>
  <add name="NewsContext" connectionString="Data Source=nevra\sqlexpress;Initial Catalog=NewsContext;Integrated Security=True;" providerName="System.Data.SqlClient" />
  </connectionStrings>

你犯了什么错误?您使用的是自动迁移还是手动迁移?你确定数据库实际上不存在吗?@ChrisPratt我正在使用自动迁移,没有错误。当然数据库无法创建,不要理解我错过了哪一步。