DKNet.EfCore.Relational.Helpers
10.1.17
See the version list below for details.
dotnet add package DKNet.EfCore.Relational.Helpers --version 10.1.17
NuGet\Install-Package DKNet.EfCore.Relational.Helpers -Version 10.1.17
<PackageReference Include="DKNet.EfCore.Relational.Helpers" Version="10.1.17" />
<PackageVersion Include="DKNet.EfCore.Relational.Helpers" Version="10.1.17" />
<PackageReference Include="DKNet.EfCore.Relational.Helpers" />
paket add DKNet.EfCore.Relational.Helpers --version 10.1.17
#r "nuget: DKNet.EfCore.Relational.Helpers, 10.1.17"
#:package DKNet.EfCore.Relational.Helpers@10.1.17
#addin nuget:?package=DKNet.EfCore.Relational.Helpers&version=10.1.17
#tool nuget:?package=DKNet.EfCore.Relational.Helpers&version=10.1.17
DKNet.EfCore.Relational.Helpers
Small set of DbContext extension methods for relational-provider bookkeeping: table creation without a migration, an already-open connection, resolved schema/table names, and table-existence checks.
Install
dotnet add package DKNet.EfCore.Relational.Helpers
Features
CreateTableAsync<TEntity>()— ensures the database exists and creates the table forTEntityif it isn't already there (one-shot, not a migration)GetDbConnection()— returns theDbContext's underlyingDbConnection, opening it if closedGetTableName<TEntity>()— resolves the schema and table name EF Core mapped forTEntity(with the SQL Serverdbodefault applied)TableExistsAsync<TEntity>()— checks whether the table forTEntityexists in the database
Quick start
using DKNet.EfCore.Relational.Helpers;
if (!await dbContext.TableExistsAsync<Product>())
{
await dbContext.CreateTableAsync<Product>();
}
var (schema, table) = dbContext.GetTableName<Product>();
Customisation reference
There is no options class, no IServiceCollection extension, and no MSBuild switch — the surface is the four
methods' parameters and the provider-dependent behaviour they inherit.
| Method | Knob | Type | Default | Effect |
|---|---|---|---|---|
CreateTableAsync<TEntity> |
TEntity |
class |
required | Picks the table whose existence is probed. Creation itself is not scoped to it — CreateTablesAsync creates every table missing from the model. |
CreateTableAsync<TEntity> |
cancellationToken |
CancellationToken |
default |
Flows into the exists check, EnsureCreatedAsync, the table probe and CreateTablesAsync. |
GetDbConnection |
cancellationToken |
CancellationToken |
default |
Used only when the connection was closed and has to be opened. |
GetTableName<TEntity> |
default schema | — | "dbo" on SQL Server, otherwise null |
Substituted only when the provider name is exactly Microsoft.EntityFrameworkCore.SqlServer and the model supplies no schema. |
GetTableName<TEntity> |
resolution order | — | GetSchema() → GetDefaultSchema() → default schema; GetTableName() → GetDefaultTableName() |
Fixed. Returns (null, null) when TEntity is not in the model. |
TableExistsAsync<TEntity> |
swallowed exception | — | DbException only |
Any DbException reads as "table absent"; everything else propagates. |
TableExistsAsync<TEntity> |
cancellationToken |
CancellationToken |
default |
Flows into the AnyAsync probe. |
All four require a relational provider, and none of them record a migration — mixing CreateTableAsync with EF
Core Migrations on the same database leaves an inconsistent __EFMigrationsHistory.
Documentation
Full method reference, gotchas, and provider notes: https://github.com/baoduy/DKNet/blob/main/docs/EfCore/DKNet.EfCore.Relational.Helpers.md
License
MIT © drunkcoding
Repository
| Product | Versions Compatible and additional computed target framework versions. |
|---|---|
| .NET | 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. |
-
net10.0
- DKNet.EfCore.Extensions (>= 10.1.17)
- Microsoft.EntityFrameworkCore (>= 10.0.11)
- Microsoft.EntityFrameworkCore.Relational (>= 10.0.11)
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 |
|---|---|---|
| 10.1.19 | 0 | 9/3/2026 |
| 10.1.18 | 0 | 9/3/2026 |
| 10.1.17 | 0 | 9/3/2026 |
| 10.1.16 | 0 | 9/3/2026 |
| 10.1.15 | 67 | 9/1/2026 |
| 10.1.14 | 66 | 9/1/2026 |
| 10.1.13 | 78 | 8/31/2026 |
| 10.1.12 | 94 | 8/25/2026 |
| 10.1.11 | 94 | 8/24/2026 |
| 10.1.10 | 89 | 8/22/2026 |
| 10.1.9 | 100 | 8/22/2026 |
| 10.1.8 | 82 | 8/21/2026 |
| 10.1.7 | 89 | 8/21/2026 |
| 10.1.6 | 85 | 8/21/2026 |
| 10.1.5 | 92 | 8/20/2026 |
| 10.1.4 | 87 | 8/20/2026 |
| 10.1.3 | 93 | 8/19/2026 |
| 10.1.2 | 89 | 8/19/2026 |
| 10.1.1 | 89 | 8/19/2026 |
| 10.0.36 | 108 | 8/18/2026 |