Skip to content

Commit 97bcae3

Browse files
committed
Updates
1 parent 59a7566 commit 97bcae3

File tree

1 file changed

+7
-7
lines changed

1 file changed

+7
-7
lines changed

aspnetcore/blazor/blazor-ef-core.md

Lines changed: 7 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -62,15 +62,15 @@ The sample app was built as a reference for server-side Blazor apps that use EF
6262

6363
The sample uses a local [SQLite](https://www.sqlite.org/index.html) database so that it can be used on any platform.
6464

65-
The sample demonstrates use of EF Core to handle optimistic concurrency. However, [native database-generated concurrency tokens](/ef/core/saving/concurrency?tabs=fluent-api#native-database-generated-concurrency-tokens) aren't supported for SQLite databases, which is the database provider for the sample app. To demonstrate concurrency with the sample app, adopt a different database provider that supports database-generated concurrency tokens (for example, the [SQL Server provider](/ef/core/providers/sql-server)).
65+
The sample demonstrates use of EF Core to handle optimistic concurrency. However, [native database-generated concurrency tokens](/ef/core/saving/concurrency?tabs=fluent-api#native-database-generated-concurrency-tokens) aren't supported for SQLite databases, which is the database provider for the sample app. To demonstrate concurrency with the sample app, adopt a different database provider that supports database-generated concurrency tokens (for example, the [SQL Server provider](/ef/core/providers/sql-server)). You can adopt SQL Server for the sample app by following the guidance in the next section, *Use the sample with SQL Server and optimistic concurrency*.
6666

6767
### Use the sample with SQL Server and optimistic concurrency
6868

6969
The sample demonstrates use of EF Core to handle optimistic concurrency but only for a database provider that uses [native database-generated concurrency tokens](/ef/core/saving/concurrency?tabs=fluent-api#native-database-generated-concurrency-tokens), which is a feature supported for SQL Server. To demonstrate concurrency with the sample app, the sample app can be converted from the SQLite provider to use the [SQL Server provider](/ef/core/providers/sql-server) with a new SQL Server database created using .NET scaffolding.
7070

7171
Use the following guidance to adopt SQL Server for the sample app using Visual Studio.
7272

73-
Open the `Program` file (`Program.cs`) and comment out the lines that add the SQLite provider:
73+
Open the `Program` file (`Program.cs`) and comment out the lines that add the database context factory with the SQLite provider:
7474

7575
```diff
7676
- builder.Services.AddDbContextFactory<ContactContext>(opt =>
@@ -87,25 +87,25 @@ In the **Add New Scaffolded Item** dialog, select **Installed** > **Common** > *
8787

8888
In the **Add Razor Components Using Entity Framework (CRUD)** dialog, use the following settings:
8989

90-
* **Template**: Leave the selection on **CRUD**.
91-
* **Model class**: Select the `Contact` model.
90+
* **Template**: Use the default selection (**CRUD**).
91+
* **Model class**: Select the `Contact` model from the dropdown list.
9292
* **DbContext class**: Select the plus sign (`+`) and select **Add** using the default context class name generated by the scaffolder.
93-
* **Database provider**: Leave the default **SQL Server** value.
93+
* **Database provider**: Use the default selection (**SQL Server**).
9494

9595
Select **Add** to scaffold the model and create the SQL Server database.
9696

9797
When the scaffolding operation completes, delete the generated context class from the `Data` folder (`Data/{PROJECT NAME}Context.cs`, where the `{PROJECT NAME}` placeholder is the project's name/namespace).
9898

9999
Delete the `ContactPages` folder from the `Components/Pages` folder, which contains [QuickGrid](xref:blazor/components/quickgrid)-based pages for contact management. For a complete demonstration of QuickGrid-based pages for managing data, use the <xref:blazor/tutorials/movie-database-app/index> tutorial.
100100

101-
Open the `Program` file (`Program.cs`) and find the line that scaffolding added to create a database context factory using the SQL Server provider. Change the context from the generated context class (deleted earlier) to the existing `ContactContext` class:
101+
Open the `Program` file (`Program.cs`) and find the line that scaffolding added to create a database context factory using the SQL Server provider. Change the context from the generated context class (deleted earlier) to the app's existing `ContactContext` class:
102102

103103
```diff
104104
- builder.Services.AddDbContextFactory<BlazorWebAppEFCoreContext>(options =>
105105
+ builder.Services.AddDbContextFactory<ContactContext>(options =>
106106
```
107107

108-
At this point, the app is using the SQL Server provider and a SQL Server database created for the `Contacts` model class. Optimistic concurrency works using [native database-generated concurrency tokens](/ef/core/saving/concurrency?tabs=fluent-api#native-database-generated-concurrency-tokens) that are already implemented in the sample app's code.
108+
At this point, the app is using the SQL Server provider and a SQL Server database created for the `Contact` model class. Optimistic concurrency works using [native database-generated concurrency tokens](/ef/core/saving/concurrency?tabs=fluent-api#native-database-generated-concurrency-tokens) that are already implemented in the sample app's `ContactContext` class.
109109

110110
### Database logging
111111

0 commit comments

Comments
 (0)