blazor-403167-common-concepts-data-binding-bind-components-to-data-with-entity-framework-core.md
Entity Framework Core (EF Core) is a data access technology. EF Core uses a model to access data. The model consists of entity classes and a context object that stores information about a connection session with a database.
You can use EF Core in Blazor Server applications with DevExpress components: Grid, Pivot Grid, Scheduler, Combo Box and so on.
Note
Refer to Blazor Server and EF Core. Blazor WebAssembly prevents most direct connections and requests to databases. If you use a WASM Blazor application, you should have a separate application for database operations.
View Example: How to bind the Grid to data with Entity Framework Core
The steps below describe how to fetch data from a database to DevExpress components.
Create a Blazor Server or Blazor WebAssembly application.
Add EF NuGet packages to your project.
Create a model for your database. In Visual Studio, select Tools → NuGet Package Manger → Package Manger Console and run the Scaffold-DbContext command.
Register a DbContext factory in the Program.cs file. Use the AddDbContextFactory extension method.
In the .razor file, do the following:
In the @code block, do the following:
Add a DevExpress component to the page and bind it to the Data collection. The following code adds Grid to the page:
Implement the Create , Update and Delete operations for the grid. To do this, add a command column to the grid and handle corresponding events. Refer to Edit Data for instructions.