locked
Integrating Owin Identity into existing DBCntext RRS feed

  • Question

  • User-895696286 posted

    Hi,

    There is an existing DbContext in the system as I am using Entity Framework Code First. After implementing Owin authentication, system has one more DbContext, IdentityDbContext,  for Owin iteself. Are there any ways I can integrating the IdentityDbContext into my existing normal DbContext?

    Thanks,

    Bo 

    Monday, July 13, 2015 4:32 PM

Answers

  • User2024324573 posted

    You can use IdentityDbContext and add your list of tables to it without using any other DbContext. In your IdentityDbContext add all your DbSets and do the migration, the tables will be created.

    • Marked as answer by Anonymous Thursday, October 7, 2021 12:00 AM
    Monday, July 13, 2015 4:36 PM
  • User1223857158 posted

    Hi Bo,

    As Mostafa said, you could use IdentityDbContext.

    I suggest you take a look at this article: http://www.asp.net/identity/overview/migrations/migrating-an-existing-website-from-sql-membership-to-aspnet-identity

    After install the Owin reference, we need to migrate the existing database to a schema required by the ASP.NET Identity system. Then, create a new class ApplicationDBContext that extends IdentityDbContext under the 'Models' folder and create new account management pages.

    Hope it can help you.

    • Marked as answer by Anonymous Thursday, October 7, 2021 12:00 AM
    Wednesday, July 15, 2015 5:29 AM

All replies

  • User2024324573 posted

    You can use IdentityDbContext and add your list of tables to it without using any other DbContext. In your IdentityDbContext add all your DbSets and do the migration, the tables will be created.

    • Marked as answer by Anonymous Thursday, October 7, 2021 12:00 AM
    Monday, July 13, 2015 4:36 PM
  • User1223857158 posted

    Hi Bo,

    As Mostafa said, you could use IdentityDbContext.

    I suggest you take a look at this article: http://www.asp.net/identity/overview/migrations/migrating-an-existing-website-from-sql-membership-to-aspnet-identity

    After install the Owin reference, we need to migrate the existing database to a schema required by the ASP.NET Identity system. Then, create a new class ApplicationDBContext that extends IdentityDbContext under the 'Models' folder and create new account management pages.

    Hope it can help you.

    • Marked as answer by Anonymous Thursday, October 7, 2021 12:00 AM
    Wednesday, July 15, 2015 5:29 AM