I am getting this error when I try to register a user etc:
Invalid object name 'dbo.AspNetUsers'.
Which gives me 2 questions:
1) How can I solve this problem
2) Why do I have this problem?! ... there are a few similar questions showing work arounds (hacks?), but nothing I've seem explains why it requires doing
I get the error when I run my website on Azure. If I run in locally (i.e. debug directly from VS IIS) on my machine it runs correctly. The locally run website is still accessing the same Azure SQL database without issue and with the same connection string:
<add name="DefaultConnection" connectionString="data source=tcp:mysqlserver.database.windows.net,1433;initial catalog=mysqldb;user id=mysqluser;password=mypass;multipleactiveresultsets=True;connect timeout=30;encrypt=True;trustservercertificate=False;application name=EntityFramework" providerName="System.Data.SqlClient" />
It can access the other tables in the database fine.
I've tried adding the user my to the databases db_owner
role.
I've tried using the sql-user from my connection string, the database name in th:
protected override void OnModelCreating(DbModelBuilder modelBuilder)
{
base.OnModelCreating(modelBuilder);
// Also tried this
//modelBuilder.HasDefaultSchema("mysqluser");
string schema = "mysqluser";
modelBuilder.Entity<IdentityRole>().ToTable("AspNetRoles", schema);
modelBuilder.Entity<IdentityUserClaim>().ToTable("AspNetUserClaims", schema);
modelBuilder.Entity<IdentityUserLogin>().ToTable("AspNetUserLogins", schema);
modelBuilder.Entity<IdentityUserRole>().ToTable("AspNetUserRoles", schema);
modelBuilder.Entity<ApplicationUser>().ToTable("AspNetUsers", schema);
}
This is mainly based on this question: ASP.Net Identity - Use custom Schema ...I haven't done the convoluted answer yet - creating a migration, edit it, apply it, delete it, apply it again - surely that's a hack around something that should work "out of the box".
Additional information: I have just re-created this database using migration so that the AspNet tables would be recreated along with my own.