Membership Issues in ASP.Net and Entity Framework Using .NET 4.5

I am studying the migration function available in the Entity Framework and I seem to have gotten into the problem. When using an Internet application project template and allowed framework migrations, etc. I'm trying to just create a default user in the database - using automatic migration:

protected override void Seed(eManager.Web.Infrastructure.DepartmentDb context)
{            
   WebSecurity.InitializeDatabaseConnection("DefaultConnection", "UserProfile", "UserId", "Email", false);

    if (!WebSecurity.UserExists("ahicks2"))
    {
        WebSecurity.CreateAccount("ahicks2", "password", requireConfirmationToken:true);
    }

    if (!Roles.RoleExists("Admin"))
    {
        Roles.CreateRole("Admin");
    }
}

When I run "Update-Database -verbose" in the package manager, I get the following error:

Seed launch method. System.Web.Security.MembershipCreateUserException: The provider encountered an unknown error.

WebMatrix.WebData.SimpleMembershipProvider.CreateAccount( userName, String, Boolean requireConfirmationToken) WebMatrix.WebData.WebSecurity.CreateAccount(String _, String, requireConfirmationToken)

- Configuration.Seed. - , , , :

<membership defaultProvider="DefaultMembershipProvider">
    <providers>
        <clear/>
        <add name="DefaultMembershipProvider" 
             type="WebMatrix.WebData.SimpleMembershipProvider, WebMatrix.WebData, Version=2.0.0.0, Culture=neutral, PublicKeyToken=31bf3856ad364e35"
             connectionStringName="DefaultConnection"/>

, -. - ? , - . - , - asp.net 2.0! . .

EDIT: , : http://forums.asp.net/t/1598261.aspx/1, .

+5
2

. MSDN : WebSecurity.CreateAccount

, ( userName) . ( , , CreateUserAndAccount (String, String, Object, Boolean).)

+5

:

WebMatrix.WebData.WebSecurity.CreateUserAndAccount("YOURUSERNAME", "YOURPASSWORD");

, , /

[InitializeSimpleMembership]

, , !

.

Dan.

0

All Articles