I have a highly standardized project in DDD (Domain-Driven Design), so it means that each layer has it's responsibilities and no layer knows other than itself and the Domain Layer.
Here's the structure of my project:
My Infra.Data
layer is responsible for connecting with the Database, and i'm persisting using EntityFramework
.
My problem is: in order to make it work with SQLServer Databases, i need to add a reference to EntityFramework.SqlServer
in my WebApplication
layer, which breaks my separation of concerns concept, as you can see below.
Even having the same reference in my Infra.Data
layer, which is where it only should be, as you can see below.
If i remove the EntityFramework.SqlServer
reference from the WebApplication
layer, it stops working, and throws exception every time i try to persist data, as you can see below.
I need to know how to remove this reference to keep separation of concerns, because the way it is now, i'll have to change my WebApplication
if i want to change my persistence. My Web layer is prohibited to even have anything with the word "EntityFramework" in it. I want FULL separation of concerns to change any layer without affecting no other.
If i register my <entityFramework>
provider in my Web.config file, it will only works if i have the EntityFramework.SqlServer
in the project, but without the EntityFramework.SqlServer
reference on the WebApplication
, it miss namespaces and complain about it.
Note: My project also connects to MySql Databases successfully, and i don't need no references to MySql.Data
or any other MySql library in my WebApplication
layer, as expected.
Please help me, my DDD/Separation of Concerns OCD is cracking on it, thanks.