3
我想使用Visual Studio 2012 NuGet包管理器控制台创建新数据库。 我已经做了所有的步骤,使迁移,迁移的文件夹已成功创建,它的配置类定义为下一个:MVC 4 - 无法使用NuGet包管理控制台创建数据库
internal sealed class Configuration : DbMigrationsConfiguration<MyMVC4Project.Infrastructure.CategoryDb>
{
public Configuration()
{
AutomaticMigrationsEnabled = true;
}
protected override void Seed(MyMVC4Project.Infrastructure.CategoryDb context)
{
context.Categories.AddOrUpdate(d => d.Name,
new Department() {Name = "dishes"},
new Department() {Name = "Appliances"},
new Department() {Name = "furniture"}
);
}
}
PM>更新数据库-Verbose
在这一点上,我看到错误消息:
Using StartUp project 'MyMVC4Project'.
Using NuGet project ' MyMVC4Project '.
Specify the '-Verbose' flag to view the SQL statements being applied to the target database.
Target database is: 'MyMVC4Project.Infrastructure.CategoryDb' (DataSource: .\SQLEXPRESS, Provider: System.Data.SqlClient, Origin: Convention).
No pending code-based migrations.
Running Seed method.
然后就没数据库在App_Data文件夹中创建,我期待找到的LocalDB数据库不是SQL Express的一个,然后安装SQL Express实例有不同的名称比“的SQLExpress” ,并在我的web.config中默认的连接字符串指向一个localDB实例。
请问我该如何解决这个问题?