The previous post contained lots of information about how dependency injection works with database providers. This post adds more to the provider story by explaining how to implement a method like UseSqlServer that allows applications to select the provider to use.
EF Core can interact with dependency injection (D.I.) in two ways:
- A D.I. container can be used to create DbContext instances
- EF uses a D.I. container internally for its own services
The first of these was covered in a previous post. This post covers how EF uses dependency injection internally and how it can interact with an external container.
This post describes the different ways to create and configure instances of DbContext in EF Core 1.1. This includes:
- Calling a constructor directly and overriding OnConfiguring
- Passing DbContextOptions to the constructor
- Using Dependency Injection (D.I.) to create instances