タイトルが示すように、私は Entity Framework 6 を使用しています。 Update-Database を呼び出すと、シード メソッドが失敗します。
SimpleMembershipProvider userMgr = new SimpleMembershipProvider();
if (WebSecurity.Initialized)
{
if (userMgr.GetUser("administrator", false) == null) //--> Throws the exception
{
userMgr.CreateUserAndAccount("administrator", "password", false, null)
...
}
}
そして、スローされる例外:
System.InvalidOperationException: You must call the "WebSecurity.InitializeDatabaseConnection" method before you call any other method of the "WebSecurity" class. This call should be placed in an _AppStart.cshtml file in the root of your site.
at WebMatrix.WebData.SimpleMembershipProvider.get_PreviousProvider()
at WebMatrix.WebData.SimpleMembershipProvider.GetUser(String username, Boolean userIsOnline)
at SomeProject.Migrations.Configuration.Seed(SomeProjectDB context) in c:\Users\Me\Documents\Visual Studio 2013\Projects\SomeProject\SomeProject 2.0\Migrations\Configuration.cs:line 73
...