1

I'll give the simplified version of my project solution. I have the following projects in my solution. MVC, Core, Data, Common. Common holds enums, static classes, data transfer objects, etc. No logic, no assemblies. The MVC layer can access Core and Common. Core can access Data and Common. Data can access Common.

I already have my classes consuming dependencies using interfaces. I want to implement Microsoft Unity for IoC. I added the UnityConfig the MVC, Core, and Data projects. I was then able to have Unity register each projects classes. This works fine and I thought I had the problem in the bag.

One of the developers on my team is telling me that I shouldn't do it that way. That I'm adding a dependency across all three layers. I can see his point and I'm wondering what the best practice is for implementing an Microsoft Unity in this environment.

The other developer wants me to add the data layer reference to the MVC project. Then Unity could be contained to just the MVC project. I really don't like the idea of putting the data layer in scope of the MVC project. I've had bad experiences with developers making direct calls with Entity and I would much rather force them to use the Core layer (Business Layer) and have the Core layer make the database call.

I'm also considering adding a separate project just for Unity to be able to see all 3 layers. It was pointed out that this could create a problem as far as having a single composition root. Not something that I had really thought about before.

I'm really hoping for a cleaver solution that doesn't include adding a reference from MVC to the data layer.

Thank you very much in advance.

artless noise
  • 21,212
  • 6
  • 68
  • 105
CubeRoot
  • 552
  • 2
  • 13
  • What is your actual question? – nemesv Aug 17 '14 at 13:38
  • 1
    possible duplicate of [Ioc/DI - Why do I have to reference all layers/assemblies in entry application?](http://stackoverflow.com/questions/9501604/ioc-di-why-do-i-have-to-reference-all-layers-assemblies-in-entry-application) – Steven Aug 17 '14 at 13:57
  • I want to know the proper way to add Unity to the MVC project so that it can resolve the data layer classes without having a dependency on the MVC project. – CubeRoot Aug 17 '14 at 14:04
  • The answers in question I referred to clearly state that is not something you should worry about. – Steven Aug 18 '14 at 11:49
  • Steven's link to "Ioc/DI - Why do I have to reference all layers/assemblies in entry application?" is exactly my problem. I'm shocked that refactoring into interfaces causes my Data project to not be included in the build. If I manually copy the data.dll into the MVC bin folder then it works. I'm eager to find an acceptable method to move the data.dll assembly into the mvc projects bin folder. It will have to be maintained throughout the projects transition through Test and Production. We use TFS to manage our builds. Can anyone point me in the right direction? Thanks. – CubeRoot Aug 18 '14 at 15:21

0 Answers0