4

Using Asp.net 4.5 and VS 2013, I would like to know how to integrate Asp.Net Identity Tables with an existing database.

So basically I would like to have db tables for Identity and my own tables in the same db.

I know Asp.Net Identity use Code First approach but I would like to use DB first approach for my existing db. I am little confuse.

How would you handle this?

Does it make sense keep Asp.Net Identity Tables in a different database that my own Tables?

2 Answers 2

2

I think that depends preety much on what you want to achieve.

Is it a single asp.Net application that you are developing or a set of different apps that would use the same database?

Here there is an answer I pretty much agree with. Separate schema and one database for one app/database. Two databases kind of beat the point of separation but three databases might be a better solution if the authorization rules remain the same.

As for the DB first approach there is a pretty good article (and code) here.

Sign up to request clarification or add additional context in comments.

1 Comment

Can the original question of the title be answered? In this voted answer, is the last question, about one or two servers, being answered. But not the one in the title. I will like to have my IdentityUser tables in the already working database. Can someone answer that, please? DB First approach does not cover that. I made another question: stackoverflow.com/questions/38082443/…. Thanks.
0

Edit your identitymodel to override model creation and point to your existing tables you have set-up

        protected override void OnModelCreating(System.Data.Entity.DbModelBuilder modelBuilder)
    {
        base.OnModelCreating(modelBuilder);

        modelBuilder.Entity<IdentityUser>().ToTable("Users");
        modelBuilder.Entity<ApplicationUser>().ToTable("Users");
        modelBuilder.Entity<IdentityUserRole>().ToTable("UserRoles");
        modelBuilder.Entity<IdentityUserLogin>().ToTable("UserLogins");
        modelBuilder.Entity<IdentityUserClaim>().ToTable("UserClaims");
        modelBuilder.Entity<IdentityRole>().ToTable("Roles");
    }

Comments

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Start asking to get answers

Find the answer to your question by asking.

Ask question

Explore related questions

See similar questions with these tags.