0

I am trying to add a module for the authentification in my ASP.NET MVC5 project. I created a new project with authentification implemented and copied the required files (models, controllers, views, IdentityConfig, Startup. Authn Startup.cs). I checked the references. Updated the namespace.

It works until I click on the submit button for registering my first user. I receive this

SQL error: Cannot attach the file “c:...\App_Data\DefaultConnection.mdf” as database “DefaultConnection”

I’ve already received this error when activating the "code first" migration, but in this case, I didn’t delete my database.

I have already created a database in my project. How would I use the database that I created instead of the defaultConnection?

1 Answers1

0

I need in fact to update the IdentityModel.cs

    public class ApplicationDbContext : IdentityDbContext<ApplicationUser>
    {
        public ApplicationDbContext()
            : base("name=EXISTING_DBContext", throwIfV1Schema: false)
        {
        }

        public static ApplicationDbContext Create()
        {
            return new ApplicationDbContext();
        }
    }

But I don't see the tables in the "server explorer".

  • Well, of course not. Did you actually *do* anything to migrate your database to production? That doesn't just happen magically by elves. You need to somehow create the same schema you have locally on your production instance, via SQL scripts, data tier application, etc. – Chris Pratt Aug 07 '17 at 18:53