9

VS 2013, Framework 4.5.1 ...

I ran Aspnet_regsql.exe to create the schema. It created the tables with an underscore in them: aspnet_Users for example. It also created the associated stored procedures. Those stored procedures do work and they add records to the tables: a user is added to aspnet_Users, for example.

When I try to use Login.aspx, it crashes on the manager.Find with the error: "Invalid object name 'dbo.AspNetUsers'."

    protected void LogIn(object sender, EventArgs e)
    {
        if (IsValid)
        {
            // Validate the user password
            var manager = new UserManager();
            ApplicationUser user = manager.Find(UserName.Text, Password.Text);
            if (user != null)
            {
                IdentityHelper.SignIn(manager, user, RememberMe.Checked);
                IdentityHelper.RedirectToReturnUrl(Request.QueryString["ReturnUrl"], Response);
            }
            else
            {
                FailureText.Text = "Invalid username or password.";
                ErrorMessage.Visible = true;
            }
        }
    }
nicomp
  • 4,344
  • 4
  • 27
  • 60
  • Did you ever find a solution to this? I'm experiencing a similar problem in that EntityFramework on VS 2013 generated tables like dbo.AspNetUsers, but when using the aspnet_regsql tool to implement Role Manager functionality, it creates dbo.aspnet_Users. – Drazen Bjelovuk Nov 11 '14 at 05:03
  • Ask.Net Identity uses code first migrations to create it's database tables. Instead of running aspnet_regsql (which would be related to the old membership providers) you want to run a database migration instead. – Brendan Green Jan 03 '16 at 12:52
  • @DrazenBjelovuk - The beauty of the Internet: some tools, such as aspnet_regsql, become outdated but the web pages persist. I ended up with a lotta manual edits and finally got it working. – nicomp Jan 03 '16 at 13:26
  • @BrendanGreen Migrate from what? Migrate how? – nicomp Jan 03 '16 at 13:26
  • 1
    From the following menu `Tools -> NuGet Package Manager -> Package Manager Console`, and then run `Update-Database -ProjectName Project.That.Defines.Context -ConnectionString "CnnStringToDatabase" -ConnectionProviderName System.Data.SqlClient"` – Brendan Green Jan 03 '16 at 20:48

1 Answers1

7

The authentication model changed between .Net VS2012 and VS2013, hence the AspNetDB tables and table structures, e.g.

dbo.aspnet_Users become dbo.AspNetUsers with totally different designs and rules (e.g. hyphen forbidden in Username)

yazan_ati
  • 263
  • 3
  • 3