DKNet.EfCore.Relational.Helpers 10.1.19

dotnet add package DKNet.EfCore.Relational.Helpers --version 10.1.19
                    
NuGet\Install-Package DKNet.EfCore.Relational.Helpers -Version 10.1.19
                    
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="DKNet.EfCore.Relational.Helpers" Version="10.1.19" />
                    
For projects that support PackageReference, copy this XML node into the project file to reference the package.
<PackageVersion Include="DKNet.EfCore.Relational.Helpers" Version="10.1.19" />
                    
Directory.Packages.props
<PackageReference Include="DKNet.EfCore.Relational.Helpers" />
                    
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 DKNet.EfCore.Relational.Helpers --version 10.1.19
                    
#r "nuget: DKNet.EfCore.Relational.Helpers, 10.1.19"
                    
#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 DKNet.EfCore.Relational.Helpers@10.1.19
                    
#: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=DKNet.EfCore.Relational.Helpers&version=10.1.19
                    
Install as a Cake Addin
#tool nuget:?package=DKNet.EfCore.Relational.Helpers&version=10.1.19
                    
Install as a Cake Tool

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 for TEntity if it isn't already there (one-shot, not a migration)
  • GetDbConnection() — returns the DbContext's underlying DbConnection, opening it if closed
  • GetTableName<TEntity>() — resolves the schema and table name EF Core mapped for TEntity (with the SQL Server dbo default applied)
  • TableExistsAsync<TEntity>() — checks whether the table for TEntity exists 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

https://github.com/baoduy/DKNet

Product 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. 
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
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
Loading failed