エラー: ファイル 'C:\Projects\eManager2\eManager.Web\App_Data\eManager.Web.Infrastructure.DepartmentDb.mdf' をデータベースとして添付できません
Web.Config の接続文字列:
<add name="DefaultConnection" connectionString="Data Source=SFP\v11.0;Initial Catalog=aspnet-eManager.Web-20131001100714;Integrated Security=SSPI;AttachDBFilename=|DataDirectory|\aspnet-eManager.Web-20131001100714.mdf" providerName="System.Data.SqlClient" />
Migrations フォルダー内の MVC Entity Framework Configuration.cs クラス:
namespace eManager.Web.Migrations
{
using System;
using System.Data.Entity;
using System.Data.Entity.Migrations;
using System.Linq;
internal sealed class Configuration : DbMigrationsConfiguration<eManager.Web.Infrastructure.DepartmentDb>
{
public Configuration()
{
AutomaticMigrationsEnabled = true;
}
protected override void Seed(eManager.Web.Infrastructure.DepartmentDb context)
{
context.Departments.AddOrUpdate
(
d => d.Name,
new Domain.Department() { Name = "Engineering" },
new Domain.Department() { Name = "Sales" },
new Domain.Department() { Name = "Marketing" },
new Domain.Department() { Name = "Human Resources" }
);
}
}
}