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-dashboard-ef-context

Repository files navigation

BI Dashboard for ASP.NET Core - Resolve 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 interface (CustomEFContextProvider class in this example) to create a service that allows you to get the EF Core Context.

  2. Call the IEFContextProvider.GetContext(String, Type) method to return a context for the specified data source.

  3. Call the AddDbContext method to register the context in the dependency injection container and specify the required connection string in the WebApplicationBuilder class.

  4. In the WebApplicationBuilder class, register the DashboardConfigurator service and configure it using the SetEFContextProvider(IEFContextProvider) method.

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

Contributors 4

  •  
  •  
  •  
  •