Fusonic.Extensions.EntityFrameworkCore
11.0.0
Prefix Reserved
dotnet add package Fusonic.Extensions.EntityFrameworkCore --version 11.0.0
NuGet\Install-Package Fusonic.Extensions.EntityFrameworkCore -Version 11.0.0
<PackageReference Include="Fusonic.Extensions.EntityFrameworkCore" Version="11.0.0" />
<PackageVersion Include="Fusonic.Extensions.EntityFrameworkCore" Version="11.0.0" />
<PackageReference Include="Fusonic.Extensions.EntityFrameworkCore" />
paket add Fusonic.Extensions.EntityFrameworkCore --version 11.0.0
#r "nuget: Fusonic.Extensions.EntityFrameworkCore, 11.0.0"
#:package Fusonic.Extensions.EntityFrameworkCore@11.0.0
#addin nuget:?package=Fusonic.Extensions.EntityFrameworkCore&version=11.0.0
#tool nuget:?package=Fusonic.Extensions.EntityFrameworkCore&version=11.0.0
EntityFrameworkCore
Package: Fusonic.Extensions.EntityFrameworkCore
All types are in the namespace Fusonic.Extensions.EntityFrameworkCore.
Query extensions
Extension methods for querying entities that must exist. They throw an EntityNotFoundException (from Fusonic.Extensions.Common.Entities) instead of returning null or throwing an InvalidOperationException. Methods taking an id require the entity to implement IEntity<TId>, IsRequired/FindRequiredAsync require IEntity (see the Common documentation).
User a = await dbContext.Users.FindRequiredAsync(userId, cancellationToken);
User b = await dbContext.Users.SingleRequiredAsync(userId, cancellationToken);
User c = await dbContext.Users.Where(u => u.IsActive).SingleRequiredAsync(u => u.Email == email, cancellationToken);
User d = await dbContext.Users.FirstOrDefaultAsync(u => u.Email == email).IsRequiredAsync();
User e = maybeUser.IsRequired(); // User? -> User
await dbContext.Users.IsRequiredAsync(userId, cancellationToken); // only checks existence
await dbContext.Users.Where(u => u.Email == email).IsRequiredAsync(cancellationToken); // only checks existence (AnyAsync)
bool exists = await dbContext.Users.ExistsAsync(userId, cancellationToken);
HasIndex
HasIndex with property expressions, which creates one (composite) index over all given properties:
builder.Entity<User>().HasIndex(u => u.LastName, u => u.FirstName);
Conventions
Provides a more sensible delete convention than EF Core's CascadeDeleteConvention. NoActionDeleteConvention sets NO ACTION instead of CASCADE on required foreign keys, and ClientSetNull on optional ones. Deleting a principal then fails as long as dependent rows exist, so the dependent rows must be deleted explicitly.
With the default EF Core behavior, it is easy to create bugs that wouldn't be caught automatically by your testing. For example when referencing a User in a History and deleting the User, the History would be deleted as well. This is most likely not the desired behavior.
Therefore, if such a behavior is intended it should either be implemented
- by manually deleting all references in code
- by explicitly overriding the delete behavior on your foreign key
- by setting the foreign key as nullable
See https://github.com/dotnet/efcore/issues/27479, https://learn.microsoft.com/en-us/ef/core/saving/cascade-delete and https://www.postgresql.org/docs/current/ddl-constraints.html#DDL-CONSTRAINTS-FK for more information.
To use this, add this to your DbContext:
using Fusonic.Extensions.EntityFrameworkCore;
using Microsoft.EntityFrameworkCore.Metadata.Conventions;
protected override void ConfigureConventions(ModelConfigurationBuilder configurationBuilder)
{
configurationBuilder.Conventions.Remove<CascadeDeleteConvention>();
configurationBuilder.Conventions.Add(static _ => new NoActionDeleteConvention());
}
| Product | Versions Compatible and additional computed target framework versions. |
|---|---|
| .NET | net11.0 is compatible. |
-
net11.0
- Fusonic.Extensions.Common (>= 11.0.0)
- Microsoft.EntityFrameworkCore (>= 11.0.0)
- Microsoft.Extensions.DependencyInjection (>= 11.0.0)
NuGet packages
This package is not used by any NuGet packages.
GitHub repositories
This package is not used by any popular GitHub repositories.
| Version | Downloads | Last Updated |
|---|---|---|
| 11.0.0 | 0 | 11/23/2026 |
| 10.3.0 | 402 | 11/9/2026 |
| 10.2.0 | 233 | 11/5/2026 |
| 10.1.0 | 3,643 | 3/18/2026 |
| 10.0.1 | 159 | 3/17/2026 |
| 10.0.0 | 434 | 11/25/2025 |
| 10.0.0-rc.2 | 210 | 11/24/2025 |
| 10.0.0-rc.1 | 185 | 9/12/2025 |
| 9.5.4 | 389 | 8/20/2025 |
| 9.5.3 | 364 | 3/28/2025 |
| 9.5.2 | 354 | 1/16/2025 |
| 9.5.0 | 404 | 10/4/2024 |
| 9.4.0 | 314 | 9/23/2024 |
| 9.3.1 | 381 | 9/11/2024 |
| 9.3.0 | 305 | 9/11/2024 |
| 9.2.0 | 324 | 8/8/2024 |
| 9.2.0-rc.3 | 173 | 8/7/2024 |
| 9.2.0-rc.2 | 132 | 8/5/2024 |
| 9.2.0-rc.1 | 158 | 8/1/2024 |
| 9.1.0 | 256 | 7/29/2024 |