1

I have a typical 3 tier project structure.

ASP.NET 5 MVC App --> BusinessLayer --> DataLayer

When I register services in the Startup.cs of the MVC app will it handle the constructor injection between the DataLayer and BusinessLayer?

i.e.

private ICustomerRepository _repository;
public CustomerManager(ICustomerRepository repository)
{
     _repository = repository;
}
Blake Rivell
  • 13,105
  • 31
  • 115
  • 231

1 Answers1

1

Yes, they will be available if you have configured them correctly. I have successfully decoupled my Data Access Layer from my MVC app using Dependency Injection. Have you actually tried doing this yourself before you posted your question, or are you having trouble getting it working?

Ian Auty
  • 847
  • 7
  • 10
  • I probably should have just tried it first. I apologize. I just realized that it works. – Blake Rivell Jan 20 '16 at 20:23
  • One more question... I noticed that when referencing the new class library (package) you can't use the new dnxcore50 in your MVC app. Is it possible to still target dnxcore50 or do I basically have to remove it? For example if I want to reference my DataLibrary from my MVC project I keep getting an intellisense error saying it is available in 45 but not core50. My current solution is to just remove the framework dnxcore50 from my mvc app and in all class libraries remove dotnet5.4 – Blake Rivell Jan 20 '16 at 20:24
  • I believe this [SO page](http://stackoverflow.com/questions/31539341/project-json-definition-dnx451-vs-dotnet-4-51) will answer your question on the different environments your app can target. Essentially, dnxcore50 is the .net core environment which is cross platform. dnxcore50 and dnx451 are not compatible with each other, however you can allow your app to target both environments. – Ian Auty Jan 20 '16 at 20:44