1

I am creating layered MVC Application that contains.

  • model layer: which is not using any reference for EF

  • Data Layer: which contains the infrastructure. (Repositories and unit of work ) and this layer referenced with Entity framework

  • Service layer

  • Web layer.

enter image description here

I am using Asp.net identity2. What I am doing is using ApplicationUser class in model layer and this leads me to reference model layer to Entity framework and Microsoft.AspNet.Identity.EntityFramework. i am asking if there is a better way to do it, especially in feel that I am repeating my self while making both data layer and model layer using a reference to entity framework?

trailmax
  • 34,305
  • 22
  • 140
  • 234
MeraSadek
  • 11
  • 4

1 Answers1

0

I don't think I completely understand your question but consider not mixing your identity model with your domain objects model:

ASP.NET Identity is a presentation layer logic and you have to consider if it's a good idea detaching it from your topmost layer (Web).

I would suggest you keep your Model or Domain project with Entity framework alone and avoid mixing it with objects that are directly related to presentation.

You can take a look at this post: https://aarcoraci.wordpress.com/2017/02/15/asp-net-mvc5-entity-framework-repository-pattern-and-unit-of-work-revisited/

aarcoraci
  • 201
  • 3
  • 9
  • Thank you . what if i need to make a navigation property between class in domain model and dbo.aspnetusers? – MeraSadek Feb 17 '17 at 11:47
  • What I have done in the past is have a property in common. ASP.Net Identity gives you access to email (which should be always unique). You can access to this via: User.Identity.Name All you have to do later is query your domain objects for a user with that same property. You can create your own property if you like, just have something in common between both tables. – aarcoraci Feb 17 '17 at 12:42