Зарегистрируйте EF Core с помощью IDbContextFactory в ASP.NET Core Mvc ⇐ C#
Зарегистрируйте EF Core с помощью IDbContextFactory в ASP.NET Core Mvc
I've created a project App.Data that contains domain objects and a base class that implements IDbContextFactory for creating a DbContext. The code is available here.
Generating the migrations in a seperate assembly works well.
What I would like to utilize the context I've created in App.Data.Sql that is created via an SqlDbContextFactory when registering entity framework within asp.net mvc.
What I want to have is something like
services.AddEntityFrameworkSqlServer() .AddDbContext(typeof(SqlDbContextFactory)) Registering it as a singleton doesn't work since when resolved complains about no provider has been configured.
services.AddSingleton(); services.AddScoped(p => p.GetRequiredService().Create());
Источник: https://stackoverflow.com/questions/440 ... t-core-mvc
I've created a project App.Data that contains domain objects and a base class that implements IDbContextFactory for creating a DbContext. The code is available here.
Generating the migrations in a seperate assembly works well.
What I would like to utilize the context I've created in App.Data.Sql that is created via an SqlDbContextFactory when registering entity framework within asp.net mvc.
What I want to have is something like
services.AddEntityFrameworkSqlServer() .AddDbContext(typeof(SqlDbContextFactory)) Registering it as a singleton doesn't work since when resolved complains about no provider has been configured.
services.AddSingleton(); services.AddScoped(p => p.GetRequiredService().Create());
Источник: https://stackoverflow.com/questions/440 ... t-core-mvc
-
- Похожие темы
- Ответы
- Просмотры
- Последнее сообщение
-
-
Как добиться того же эффекта, что и ASP.Net MVC Server.Transfer в ASP.Net Core MVC?
Anonymous » » в форуме C# - 0 Ответы
- 98 Просмотры
-
Последнее сообщение Anonymous
-
-
-
Как добиться того же эффекта, что и ASP.NET MVC Server.Transfer в ASP.NET Core MVC?
Anonymous » » в форуме C# - 0 Ответы
- 105 Просмотры
-
Последнее сообщение Anonymous
-
-
-
Реализация выхода из Azure B2C в приложениях ASP.NET Core MVC и ASP.NET MVC.
Anonymous » » в форуме C# - 0 Ответы
- 109 Просмотры
-
Последнее сообщение Anonymous
-