You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
Copy file name to clipboardExpand all lines: aspnetcore/blazor/blazor-ef-core.md
+7-5Lines changed: 7 additions & 5 deletions
Display the source diff
Display the rich diff
Original file line number
Diff line number
Diff line change
@@ -5,7 +5,7 @@ description: Learn how to use Entity Framework Core (EF Core) in Blazor apps.
5
5
monikerRange: '>= aspnetcore-3.1'
6
6
ms.author: riande
7
7
ms.custom: mvc
8
-
ms.date: 01/13/2025
8
+
ms.date: 01/16/2025
9
9
uid: blazor/blazor-ef-core
10
10
---
11
11
# ASP.NET Core Blazor with Entity Framework Core (EF Core)
@@ -46,7 +46,7 @@ For Microsoft Azure services, we recommend using *managed identities*. Managed i
46
46
47
47
## Build a Blazor movie database app tutorial
48
48
49
-
For a tutorial experience building an app that uses EF Core to work with a database, see <xref:blazor/tutorials/movie-database-app/index>. The tutorial shows you how to create a Blazor Web App that can display and manage movies in a movie database.
49
+
For a tutorial experience building an app that uses EF Core for database operations, see <xref:blazor/tutorials/movie-database-app/index>. The tutorial shows you how to create a Blazor Web App that can display and manage movies in a movie database.
50
50
51
51
:::moniker-end
52
52
@@ -63,9 +63,9 @@ The following recommendations are designed to provide a consistent approach to u
63
63
* Consider using one context per operation. The context is designed for fast, low overhead instantiation:
64
64
65
65
```csharp
66
-
usingvarcontext=newMyContext();
66
+
usingvarcontext=newProductsDatabaseContext();
67
67
68
-
returnawaitcontext.MyEntities.ToListAsync();
68
+
returnawaitcontext.Products.ToListAsync();
69
69
```
70
70
71
71
* Use a flag to prevent multiple concurrent operations:
@@ -88,7 +88,7 @@ The following recommendations are designed to provide a consistent approach to u
88
88
}
89
89
```
90
90
91
-
Place operations after the `Loading = true;` line in the `try` block.
91
+
Place database operations after the `Loading = true;` line in the `try` block.
92
92
93
93
Thread safety isn't a concern, so loading logic doesn't require locking database records. The loading logic is used to disable UI controls so that users don't inadvertently select buttons or update fields while data is fetched.
94
94
@@ -109,6 +109,8 @@ The recommended approach to create a new <xref:Microsoft.EntityFrameworkCore.DbC
109
109
110
110
:::moniker range="< aspnetcore-5.0"
111
111
112
+
In versions of .NET prior to 5.0, use the following `DbContextFactory`:
0 commit comments