asp.net - Using the Unity IOC to inject dbcontext into my controllers and service layer? -
How can I inject my dbcontext with the Unity IOC in the service level, specifically I want to make sure that I only have one DBnettext and I want to make sure that it has been destroyed at the right time, even though I am using async.
My application uses EF6 and a generic repository, there are so many codes and I have decided that I would like to remove the generic repository, EF6 as my repositories as my UOE and DBSet Use the context. This will be seen by highly experienced developers here as suggested by the SEO. Keep in mind that I do not want to change my ORM database There are less than 20 tables in the application and I have several ways that I can test it without using any other repository.
I'm not sure what you mean by injecting your DB reference into your "service level" But suppose that you mean ASP.NET MVC website based on tags, you want to set up your container with the global dependency reseller
class and make sure that your references Ready to request with lifetime.
You can get a good breakdown of dependency injection in MVC.
Comments
Post a Comment