I am very new to ASP.NET Core.
If I create 4 projects like this:
MyApplication
|-- MyApplication.DataAccess
|-- MyApplication.Provider
|-- MyApplication.Service
|-- MyApplication.ViewModel
DataAccess
project is for getting data from the database, Provider
for the queries, Service
project for business logic, and lastly ViewModel
for the data representation.
The dependency is like this:
MyApplication.DataAccess -> MyApplication.Provider -> MyApplication.Service
and also:
MyApplication.ViewModel -> MyApplication.Service
My target is to later create an application named MyApplication.Web.UI
for the Razor pages.
I am very confused on how to create a dependency injection in the case of class library in C#. Is there any way for me to use DI Service or is it better to use using
scope for my DBContext
?
And lastly, is there a way where I can convert the DataAccess
models into view models in the Service
project without making the Service
project depending on the DataAccess
project?