DbContextOptionsBuilder<TContext>.UseInternalServiceProvider Method
Definition
Important
Some information relates to prerelease product that may be substantially modified before it’s released. Microsoft makes no warranties, express or implied, with respect to the information provided here.
Sets the IServiceProvider that the context should resolve all of its services from. EF will create and manage a service provider if none is specified.
public virtual Microsoft.EntityFrameworkCore.DbContextOptionsBuilder<TContext> UseInternalServiceProvider (IServiceProvider serviceProvider);
public virtual Microsoft.EntityFrameworkCore.DbContextOptionsBuilder<TContext> UseInternalServiceProvider (IServiceProvider? serviceProvider);
override this.UseInternalServiceProvider : IServiceProvider -> Microsoft.EntityFrameworkCore.DbContextOptionsBuilder<'Context (requires 'Context :> Microsoft.EntityFrameworkCore.DbContext)>
Public Overridable Function UseInternalServiceProvider (serviceProvider As IServiceProvider) As DbContextOptionsBuilder(Of TContext)
Parameters
- serviceProvider
- IServiceProvider
The service provider to be used.
Returns
The same builder instance so that multiple calls can be chained.
Remarks
The service provider must contain all the services required by Entity Framework (and the database being used). The Entity Framework services can be registered using an extension method on IServiceCollection. For example, the Microsoft SQL Server provider includes an AddEntityFrameworkSqlServer() method to add the required services.
If the IServiceProvider has a DbContextOptions or DbContextOptions<TContext> registered, then this will be used as the options for this context instance.
See Using DbContextOptions for more information and examples.
Applies to
Entity Framework