FclEx.EfCore 2.4.0

There is a newer version of this package available.
See the version list below for details.
dotnet add package FclEx.EfCore --version 2.4.0
                    
NuGet\Install-Package FclEx.EfCore -Version 2.4.0
                    
This command is intended to be used within the Package Manager Console in Visual Studio, as it uses the NuGet module's version of Install-Package.
<PackageReference Include="FclEx.EfCore" Version="2.4.0" />
                    
For projects that support PackageReference, copy this XML node into the project file to reference the package.
<PackageVersion Include="FclEx.EfCore" Version="2.4.0" />
                    
Directory.Packages.props
<PackageReference Include="FclEx.EfCore" />
                    
Project file
For projects that support Central Package Management (CPM), copy this XML node into the solution Directory.Packages.props file to version the package.
paket add FclEx.EfCore --version 2.4.0
                    
#r "nuget: FclEx.EfCore, 2.4.0"
                    
#r directive can be used in F# Interactive and Polyglot Notebooks. Copy this into the interactive tool or source code of the script to reference the package.
#:package FclEx.EfCore@2.4.0
                    
#:package directive can be used in C# file-based apps starting in .NET 10 preview 4. Copy this into a .cs file before any lines of code to reference the package.
#addin nuget:?package=FclEx.EfCore&version=2.4.0
                    
Install as a Cake Addin
#tool nuget:?package=FclEx.EfCore&version=2.4.0
                    
Install as a Cake Tool

FclEx.EfCore

Entity Framework Core helpers for FclEx.

What Is Included

  • Query helpers for EF Core IQueryable and DbContext workflows.
  • Update and change-application helpers.
  • Context service-registration helpers.
  • Soft-delete helpers and entity-state utilities.
  • Relational schema and physical-table truncation helpers.
  • SSH tunnel helpers for database access during local or integration workflows.
  • Test-model and test-data conveniences used by EF-oriented tests.

Usage Notes

  • This package targets net8.0, net9.0, and net10.0.
  • It depends on Microsoft.EntityFrameworkCore.Relational and FclEx.Core.
  • Keep provider-specific SQL behavior in application code or provider-specific packages.

Truncating a table

await context.TruncateAsync<Customer>(cancellationToken);
await context.Set<Customer>().TruncateAsync(cancellationToken);
await context.TruncateAsync(context.Model.FindEntityType(typeof(Customer))!, cancellationToken);

TruncateAsync removes every row from the entity's entire physical table, ignoring query filters and soft-delete rules. It does not synchronize tracked entities. Only exclusive, single-table mappings without inheritance are supported; multi-table and shared-table mappings are rejected. A named shared-type entity set is supported when it owns its table exclusively; use the DbSet or IEntityType overload to preserve its identity. The IEntityType overloads require metadata from the context's runtime model; metadata from a different model throws ArgumentException.

SQL Server, PostgreSQL, and the Oracle, Pomelo, and Microting MySQL providers are supported. SQLite and unknown providers throw NotSupportedException; no DELETE fallback is performed. SQL Server and MySQL reset identity values, while PostgreSQL preserves them when using the overloads without boolean options.

The overloads accepting restartIdentity and cascade require both boolean values explicitly, with no defaults:

await context.TruncateAsync<Customer>(restartIdentity: true, cascade: false, cancellationToken: cancellationToken);

PostgreSQL supports all combinations, generating RESTART IDENTITY or CONTINUE IDENTITY, and optionally CASCADE. SQL Server and MySQL accept only restartIdentity: true, cascade: false; other combinations throw NotSupportedException before opening the connection. PostgreSQL CASCADE can truncate additional referencing tables, including tables outside the EF model. Mapping validation applies only to the target table.

Foreign keys and other database restrictions may prevent truncation. The command uses the current transaction, if any, without starting a transaction or retrying through an execution strategy. Transaction semantics follow the database: MySQL TRUNCATE causes an implicit commit and cannot be rolled back like an ordinary delete.

Keywords with LIKE wildcards

ContainsAny treats keywords literally by default. Pass escapeWildcards: false to allow % (zero or more characters) and _ (one character) in keywords:

query.ContainsAny(x => x.Name, ["foo%bar", "item_"], escapeWildcards: false);

Each keyword is still surrounded by % for substring matching. Backslashes remain literal in both modes; a backslash cannot escape an individual wildcard in this input format. Opening square brackets are escaped by default for SQL Server. For Oracle, pass escapeBrackets: false: brackets are already literal, and LIKE ... ESCAPE rejects a backslash followed by a bracket. This option is independent of escapeWildcards. Use QueryableHelper.BuildLike for a provider-ready pattern with explicit control over the entire LIKE expression.

Re-registering a context

Call RemoveDbContext<TContext>() before AddDbContext<TContext>() to replace an existing context registration with new options or lifetimes:

services.RemoveDbContext<AppDbContext>();
services.AddDbContext<AppDbContext>(options => options.UseSqlite(connectionString));

This removes every registration for TContext and DbContextOptions<TContext>, plus IDbContextOptionsConfiguration<TContext> on EF Core 9 and later. Repeated calls are harmless, and registrations for other context types are preserved.

Use it before building the service provider. It does not remove service aliases, context factories, pooling services, or non-generic DbContextOptions registrations. The remaining non-generic options registrations can fail to resolve until the typed options are registered again. Existing providers and context instances are unaffected.

Product Compatible and additional computed target framework versions.
.NET net8.0 is compatible.  net8.0-android was computed.  net8.0-browser was computed.  net8.0-ios was computed.  net8.0-maccatalyst was computed.  net8.0-macos was computed.  net8.0-tvos was computed.  net8.0-windows was computed.  net9.0 is compatible.  net9.0-android was computed.  net9.0-browser was computed.  net9.0-ios was computed.  net9.0-maccatalyst was computed.  net9.0-macos was computed.  net9.0-tvos was computed.  net9.0-windows was computed.  net10.0 is compatible.  net10.0-android was computed.  net10.0-browser was computed.  net10.0-ios was computed.  net10.0-maccatalyst was computed.  net10.0-macos was computed.  net10.0-tvos was computed.  net10.0-windows was computed. 
Compatible target framework(s)
Included target framework(s) (in package)
Learn more about Target Frameworks and .NET Standard.

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
2.4.2 155 10/10/2026
2.4.1 106 10/8/2026
2.4.0 121 10/3/2026
2.3.9 131 9/27/2026
2.3.8 105 9/26/2026
2.3.7 119 9/24/2026
2.3.6 132 9/22/2026
2.3.5 106 9/22/2026
2.3.4 160 8/28/2026
2.3.3 172 8/22/2026
2.3.2 135 8/20/2026
2.3.1 119 8/19/2026
2.3.0 132 8/17/2026
2.2.9 160 7/18/2026
2.2.8 193 6/13/2026
2.2.6 144 6/8/2026
2.2.5 146 6/5/2026
2.2.4 127 6/5/2026
2.2.3 181 5/27/2026
2.2.2 147 5/26/2026
Loading failed