ASP.NET Core AddContext

asp.net-core dbcontext entity-framework-core

Question

I'm architecting a new App and I really unconfortable with this approach in ASP.NET Core that made "normal" adding a DbContext by using AddDbContext, in services.

I'd like to know if you guys think that using AddDbContext in ASP.NET Core isn't a bad practice, since it forces my Web App to have a dependecy on my database access layer.

I've researched a lot and it was incredible that there isn't almost anything that cover this subject.

How should I proceed to overcome this concern?

Thanks!

1
0
12/17/2018 6:32:05 PM

Popular Answer

it forces my Web App to have a dependency on my database access layer

That's exactly the place where it should be: the composition root. Your application startup code is the place where you glue your components together.

What else would you want, create a separate library, containing interfaces for all classes in your entire DAL, and wire that up using magic during startup?

4
12/18/2018 3:18:40 AM


Related Questions





Related

Licensed under: CC-BY-SA with attribution
Not affiliated with Stack Overflow
Licensed under: CC-BY-SA with attribution
Not affiliated with Stack Overflow