- First, we add EF as an injected service:
public void ConfigureServices(IServiceCollection services) { services.AddEntityFramework()}
IntelliSense can help us to find this method, which already exists as an extension method helper.
- Next, we associate EF with a database. EF doesn't know anything about the data store we will use (any relational database, any nonrelational database, and so on):
public void ConfigureServices(IServiceCollection services) { services.AddEntityFramework() .AddSqlServer() }
- Now we add the DbContext named ApplicationDbContext associated with the connection in the parameter stored in appsettings.json.
In doing this, we configure a database provider when setting up the services for our application: ...