Skip to content

The following example shows how to obtain the Entity Framework Core context from the ASP.NET Core dependency injection container.

License

Notifications You must be signed in to change notification settings

DevExpress-Examples/asp-net-core-reporting-ef-context

Repository files navigation

Reporting for ASP.NET Core - Resolve the Entity Framework Core Context from the DI Container

The following example obtains Entity Framework Core context from an ASP.NET Core dependency injection container.

  1. Implement the IEFContextProvider and IEFContextProviderFactory interfaces (CustomEFContextProvider and CustomEFContextProviderFactory classes in this example) to create a service that allows you to obtain EF Core Context.

  2. Register the context in the dependency injection container. Call the AddDbContext method in the ConfigureServices method of the Startup class to specify the required connection string.

  3. Use the ConfigureServices method of the Startup class to register the factory implementation.

Files to Review

Documentation

Does this example address your development requirements/objectives?

(you will be redirected to DevExpress.com to submit your response)

About

The following example shows how to obtain the Entity Framework Core context from the ASP.NET Core dependency injection container.

Topics

Resources

License

Stars

Watchers

Forks