locked
IdentityDbContext alternative DataContext RRS feed

  • Question

  • User-1045082127 posted

    hello body

    I have been used a default asp.net identity template and nothing changes was  applied except table name which is on the on model creating:

                modelBuilder.Entity<ApplicationUser>().ToTable("tbUser");
    

    but I used another tables which have a different structure(beside IdentityDataContext) and I should declare those of thats by ADO.NET Entity Data Model which is created automatically

    and derived from DataContext.

    is there any way to use only IdentityDataContext for my another tables and Identity Structure instead of use DataContext and IdentityDataContext besides?

    Sunday, July 1, 2018 7:16 AM

All replies

  • User1724605321 posted

    Hi aminoraya,

    Not sure about your scenario , but if you want you add more tables to the identity context ,  you can modify ApplicationDbContext in  IdentityModels.cs :

    public class ApplicationDbContext : IdentityDbContext<ApplicationUser>
    {
    public ApplicationDbContext()
        : base("ApplicationDbContext", throwIfV1Schema: false)
    {
    }
    
    public DbSet<Department> Departments { get; set; }
    public DbSet<Student> Students { get; set; }
    
    public static ApplicationDbContext Create()
    {
        return new ApplicationDbContext();
    }
    }

    If i misunderstand your requirement , please feel free to let me know .

    Best Regards,

    Nan Yu

    Monday, July 2, 2018 6:03 AM