Skip to content
  • Categories
  • Recent
  • Tags
  • Popular
  • World
  • Users
  • Groups
Skins
  • Light
  • Cerulean
  • Cosmo
  • Flatly
  • Journal
  • Litera
  • Lumen
  • Lux
  • Materia
  • Minty
  • Morph
  • Pulse
  • Sandstone
  • Simplex
  • Sketchy
  • Spacelab
  • United
  • Yeti
  • Zephyr
  • Dark
  • Cyborg
  • Darkly
  • Quartz
  • Slate
  • Solar
  • Superhero
  • Vapor

  • Default (No Skin)
  • No Skin
Collapse
Code Project
  1. Home
  2. General Programming
  3. C#
  4. ASP.Net Identity with EF tier'd architecture

ASP.Net Identity with EF tier'd architecture

Scheduled Pinned Locked Moved C#
asp-netcsharpsysadminbusinessarchitecture
6 Posts 2 Posters 0 Views 1 Watching
  • Oldest to Newest
  • Newest to Oldest
  • Most Votes
Reply
  • Reply as topic
Log in to reply
This topic has been deleted. Only users with topic management privileges can see it.
  • S Offline
    S Offline
    Simon Lee Shugar
    wrote on last edited by
    #1

    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

    N 1 Reply Last reply
    0
    • S Simon Lee Shugar

      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

      N Offline
      N Offline
      Nico Haslberger
      wrote on last edited by
      #2

      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

      S 1 Reply Last reply
      0
      • N Nico Haslberger

        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

        S Offline
        S Offline
        Simon Lee Shugar
        wrote on last edited by
        #3

        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

        N 1 Reply Last reply
        0
        • S Simon Lee Shugar

          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

          N Offline
          N Offline
          Nico Haslberger
          wrote on last edited by
          #4

          No you have the IdentityDbContext in in your MVC application and in the DataAccess layer your regular DbContext.

          S 1 Reply Last reply
          0
          • N Nico Haslberger

            No you have the IdentityDbContext in in your MVC application and in the DataAccess layer your regular DbContext.

            S Offline
            S Offline
            Simon Lee Shugar
            wrote on last edited by
            #5

            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

            N 1 Reply Last reply
            0
            • S Simon Lee Shugar

              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

              N Offline
              N Offline
              Nico Haslberger
              wrote on last edited by
              #6

              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

              1 Reply Last reply
              0
              Reply
              • Reply as topic
              Log in to reply
              • Oldest to Newest
              • Newest to Oldest
              • Most Votes


              • Login

              • Don't have an account? Register

              • Login or register to search.
              • First post
                Last post
              0
              • Categories
              • Recent
              • Tags
              • Popular
              • World
              • Users
              • Groups