filmov
tv
Using IDbContextFactory and DbContext In The Same #AspNetCore app
Показать описание
Sometimes we need to work with both the regular DbContext and with IDbContextFactory at the same Asp.Net Core app. Here are two popular use cases:
1️⃣ Blazor Server, when we need to have both components and controllers and Razor Pages in the same project
2️⃣ When running background jobs, like Hangfire.
❗❗❗❗There's however a nasty exception just around the corner. If we try to run the application, we'll get an exception saying that a scoped service can't be consumed in a singleton service.
🤔So, what's wrong? Let me walk you through this.
Join this channel to get source code access and other perks:
Also follow me here (especially if you are a self taught developer):
Contents
1. Intro: 00:00
2. Do we even need this? 01:02
3. Throwing Blazor Server in the mix 03:52
4. Annoying exception: 05:13
5. C'mon. it's that simple?! 07:32
6. Conclusion: 09:37
My setup:
1️⃣ Blazor Server, when we need to have both components and controllers and Razor Pages in the same project
2️⃣ When running background jobs, like Hangfire.
❗❗❗❗There's however a nasty exception just around the corner. If we try to run the application, we'll get an exception saying that a scoped service can't be consumed in a singleton service.
🤔So, what's wrong? Let me walk you through this.
Join this channel to get source code access and other perks:
Also follow me here (especially if you are a self taught developer):
Contents
1. Intro: 00:00
2. Do we even need this? 01:02
3. Throwing Blazor Server in the mix 03:52
4. Annoying exception: 05:13
5. C'mon. it's that simple?! 07:32
6. Conclusion: 09:37
My setup:
Using IDbContextFactory and DbContext In The Same #AspNetCore app
Are You Using the DbContext in Background Services PROPERLY?
EFCore 7 Context Factory, multiple context's that can connect at runtime (Dotnet Core / Dotnet ...
DON'T Use DbContext In Blazor Interactive Server Components! (.NET8)
Using Multiple EF Core DbContexts in a Single Application
How to use EF 6 many-to-many with IDbContextFactory in Blazor Server
Entity Framework Core multiple connection strings on same DBContext?
Blazor Server EF Core 5 AddDbContextFactory
playing with dotnet core 50 - dataStorage17 AddDbContext AddDbContextPool for dependency injection
Multiple DbContext in a Single Project #dotnet #ef #csharp
C# : Use DbContext in ASP .Net Singleton Injected Class
Blazor Server Why Use DbContextFactory
EF Core 7 🚀 Multiple Databases, DbContexts & Relationships (Entity Framework 7)
C# : Avoid Entity Framework Error with Multiple Tasks Running Concurrently on Same DbContext
How do I implement DbContext inheritance for multiple databases in EF7 / .NET Core
C# : Entity Framework Core: A second operation started on this context before a previous operation c
Entity Framework Community Standup - Introducing EF Core Compiled Models
C# : How do I inject a connection string into an instance of IDbContextFactory T ?
15. Setup Program.cs to use DbContext to .NET core - ASP.NET Core MVC (.NET 6) - codeGPT
Mejora Performance de conexiones a bases de datos con IDBContextFactory
Let's fix your EF Core exceptions in Blazor Server apps
.NET Data Community Standup - DbContext Configuration and Lifetime - EF Core Architecture Part 2
How to create multiple DbContexts that target the same database and tables
Is THIS The Coolest EF7 Feature?
Комментарии