James
James

Reputation: 2009

unity.mvc3 and Unit of Work in ntier app?

Slowly putting an MVC app together with class libraries: MVC > Services > IRepository > EFRepository. Now at the moment, my EFRepository implementations each create a new dbContext in their constructor but this prevents testing so I need to inject the dbContext instead.

I am successfully using unity.mvc3 for DI throughout the rest of my app but am confused as to how to correctly implement the dbContext injection.

Think I'm just a bit lost on where to go from here. I was thinking that I should have a Unit of Work but it seems to me this would happen at the service layer.

All help appreciated,

James

Upvotes: 1

Views: 400

Answers (1)

Daniel
Daniel

Reputation: 990

  • Yes (but you could wrap into a custom unit of work)
  • Yes
  • Yes (Hierarchical lifetime manager in Unity.MVC3)

Upvotes: 3

Related Questions