Back to Devexpress

Bind Components to Data with Entity Framework Core

blazor-403167-common-concepts-data-binding-bind-components-to-data-with-entity-framework-core.md

latest2.4 KB
Original Source

Bind Components to Data with Entity Framework Core

  • Jan 20, 2026
  • 4 minutes to read

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.

  1. Create a Blazor Server or Blazor WebAssembly application.

  2. Add EF NuGet packages to your project.

  3. Create a model for your database. In Visual Studio, select ToolsNuGet Package MangerPackage Manger Console and run the Scaffold-DbContext command.

  4. Register a DbContext factory in the Program.cs file. Use the AddDbContextFactory extension method.

  5. In the .razor file, do the following:

  6. In the @code block, do the following:

  7. Add a DevExpress component to the page and bind it to the Data collection. The following code adds Grid to the page:

  8. 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.