Questions about using Ninject
Context:
To manage dependencies in an MVC application, you implemented Ninject and injected DbContext in controllers' constructors. However, you have some concerns about the cleanup, flexibility, and efficiency of this setup.
Questions:
Cleanup and Disposal of DbContext:
Reducing Boilerplate for Controller Initialization:
Optimizing Creation of DbContext:
Answers:
Cleanup and Disposal:
Reducing Boilerplate:
Optimizing Creation:
The cost of creating a DbContext instance can vary depending on the context. However, there are strategies to minimize its impact:
The above is the detailed content of Ninject and DbContext: How to Ensure Efficient Cleanup, Reduce Boilerplate, and Optimize Creation?. For more information, please follow other related articles on the PHP Chinese website!