Skip to main content
net8.0net9.0

An adapter for using the Fluent UI Blazor DataGrid with Entity Framework.

Published
Mar 19, 2025
1y ago
Total Downloads
305.4K
305,403

Install

dotnet add package Microsoft.FluentUI.AspNetCore.Components.DataGrid.EntityFrameworkAdapter --version 4.11.7
ProductVersions
.NET
net8.0net9.0

README

About

Use this package if the data you want to display in the FluentDataGrid (component in the Microsoft.FluentUI.AspNetCore.Components library) comes from EF Core:

EF Core's DataContext gives you a DbSet property for each table in your database. Simply supply this as the grid's Items parameter:

@inject ApplicationDbContext MyDbContext

<FluentDataGrid Items="@MyDbContext.People">
    ...
</FluentDataGrid>

You may also use any EF-supported LINQ operator to filter the data before passing it:

@inject ApplicationDbContext MyDbContext

<FluentDataGrid Items="@MyDbContext.Documents.Where(d => d.CategoryId == currentCategoryId)">
    ...
</FluentDataGrid>

The FluentDataGrid recognizes EF-supplied IQueryable instances and knows how to resolve queries asynchronously for efficiency.

Installation

Install the package by running the command:

dotnet add package Microsoft.FluentUI.AspNetCore.Components.DataGrid.EntityFrameworkAdapter

Usage

When using the provided implementation, you need to add add the following in the Program.cs file:

builder.Services.AddDataGridEntityFrameworkAdapter();

Changing the adapter's behavior

Starting with v4.11.4, the EntityFrameworkAsyncQueryExecutor exposes a way to ignore exceptions which may occur during query execution. This can be useful when you want to handle exceptions in a custom way, for example, by logging them. To ignore exceptions, you can supply a Func<Exception, bool> to the IgnoreException property of the EntityFrameworkAsyncQueryExecutor instance. The function should return true if the exception should be ignored and false otherwise. An example:

builder.Services.AddFluentUIComponents()
    .AddDataGridEntityFrameworkAdapter(ex => ex is SqlException sqlEx
        && sqlEx.Errors.OfType<SqlError>().Any(e => (e.Class == 11 && e.Number == 0) || (e.Class == 16 && e.Number == 3204)));

For more information see also https://github.com/microsoft/fluentui-blazor/issues/3269.

Support

The Microsoft Fluent UI Blazor library is an open source project and is not an official part of ASP.NET Core, which means it’s not officially supported and isn’t committed to ship updates as part of any official .NET updates. It is built and maintained by Microsoft employees (and other contributors) and offers support, like most other open source projects, on a best effort base through the GitHub repository only.

Changes from Previous Version

No structural changes between v4.11.6 and v4.11.7.

Adoption Assessment

A verified publisher signal is available. Assess fit from the package's supported frameworks, license and dependency graph rather than popularity alone.

Compatibility metadata lists 2 target frameworks; confirm the exact target used by your application.

Related Guides & Workflows

Learn how to evaluate, integrate, or audit this package in your .NET project.