3

Today I need some suggestion with one of the issue I am current struggling with

I am working on a project which has 3 layers

1) DAL
2) BAL
3) Web
4) Entities (This is a separate project which contain only the entities 
         that will be use to create DB tables with EF Code first)

Entities being reference in all the 3 layers
DAL being referenced in BAL and Web
BAL being referenced in Web

I want to get DAL reference out from Web project, my Web project usually talk with BAL all the time. The only reason I have to referenced DAL because of ASP.NET Identity Startup.Auth.cs and IdentityConfig.cs classes. Each of the file contain a single line of code that need an access to my DBContext which resides inside my DAL project.

IdentityConfig.cs:

var manager = new ApplicationUserManager
         (new UserStore<ApplicationUser>(context.Get<MyDbContext>()));

Startup.Auth.cs:

 app.CreatePerOwinContext(MyDbContext.Create);

How could I possible adjust things that I don't have to reference DAL inside Web project? Can you please suggest

Thanks

Ammar Khan
  • 2,565
  • 6
  • 35
  • 60
  • You may find [this question](http://stackoverflow.com/questions/27345773/i-need-help-on-structuring-new-asp-mvc-app) useful. The main idea is to place your `ApplicationUser` class inside some common assembly (`Entities` in your case). The additional benefit of that refactoring is that you'll have a single `DbContext` for both domain and ASP.NET Identity entities. For more details on that topic, have a look at [this question](http://stackoverflow.com/questions/26807810/mvc5-identity-multiple-context-in-entityframework). – Sergey Kolodiy Dec 25 '14 at 20:16
  • Unfortunately, my app structured little different than the suggested one. I don't think this work in my case until I change accordingly which I can't – Ammar Khan Dec 25 '14 at 20:25

1 Answers1

1

You are creating a 4 layer architecture. Implement the corresponding logic in Data Access Layer and reference it in Business Layer. So finally you can refer only BL in your Web.