ASP.Net Identity with EF tier'd architecture
-
I have started a new project and using the following MVC5, EF6 - Code First, ASP.NET Identity with a tier'd architecture. What I want to do is decouple the ASP.NET Identity so I can customise the ApplicationUser in my data (core) layer which is mapped to my business / service layers. Does this make sense and has anyone done anything similar? My solution is layered as follows; Solution --Presentation Layer ----MVC5 App --Business / Services Layers ----UserService ----Models (Business Objects) --Infrastructure Layer ----Data (EF Models) --------ApplicationUser ----DataAccess (Repos etc) --------DbContext
Simon Lee Shugar (Software Developer) www.simonshugar.co.uk "If something goes by a false name, would it mean that thing is fake? False by nature?" By Gilbert Durandil
-
I have started a new project and using the following MVC5, EF6 - Code First, ASP.NET Identity with a tier'd architecture. What I want to do is decouple the ASP.NET Identity so I can customise the ApplicationUser in my data (core) layer which is mapped to my business / service layers. Does this make sense and has anyone done anything similar? My solution is layered as follows; Solution --Presentation Layer ----MVC5 App --Business / Services Layers ----UserService ----Models (Business Objects) --Infrastructure Layer ----Data (EF Models) --------ApplicationUser ----DataAccess (Repos etc) --------DbContext
Simon Lee Shugar (Software Developer) www.simonshugar.co.uk "If something goes by a false name, would it mean that thing is fake? False by nature?" By Gilbert Durandil
I already did that, but it is very time-consuming and annoying. I created a layer to map the ASP.NET Identity models to my custom models and overrided all methods of the UserStore to implement my custom data access logic. Probably the easiest way is a second database context that is only responsible for the Identity system. greetings Nico
-
I already did that, but it is very time-consuming and annoying. I created a layer to map the ASP.NET Identity models to my custom models and overrided all methods of the UserStore to implement my custom data access logic. Probably the easiest way is a second database context that is only responsible for the Identity system. greetings Nico
So in my DataAccess I would have my regular DbContext and IdentityDbContext and just use a database initializer for in app start / global?
Simon Lee Shugar (Software Developer) www.simonshugar.co.uk "If something goes by a false name, would it mean that thing is fake? False by nature?" By Gilbert Durandil
-
So in my DataAccess I would have my regular DbContext and IdentityDbContext and just use a database initializer for in app start / global?
Simon Lee Shugar (Software Developer) www.simonshugar.co.uk "If something goes by a false name, would it mean that thing is fake? False by nature?" By Gilbert Durandil
No you have the IdentityDbContext in in your MVC application and in the DataAccess layer your regular DbContext.
-
No you have the IdentityDbContext in in your MVC application and in the DataAccess layer your regular DbContext.
Hmm how will the IdentityDbContext know about my ApplicationUser in my data (EF Models) solution? Hmmm may give it a rest for tonight mind is not working correctly
Simon Lee Shugar (Software Developer) www.simonshugar.co.uk "If something goes by a false name, would it mean that thing is fake? False by nature?" By Gilbert Durandil
-
Hmm how will the IdentityDbContext know about my ApplicationUser in my data (EF Models) solution? Hmmm may give it a rest for tonight mind is not working correctly
Simon Lee Shugar (Software Developer) www.simonshugar.co.uk "If something goes by a false name, would it mean that thing is fake? False by nature?" By Gilbert Durandil
The IdentityDbContext has already all Identity related models defined. If you like to customize it, do it like I described it previously: Create a layer that is derived from UserStore, override all methods and fill them with you custom logic, and map the identity models to your custom models. AND VERY IMPORTANT: If you don´t want that the UserStore uses a default DbContext you have to define an invalid connection string in the constructor of the UserStore! greetings