Part of DKNet.EfCore.Relational.Helpers. Query INFORMATION_SCHEMA.TABLES using the entity mapped table and, when known, schema.
Use the Quick Start console project. Set DKNET_DOCS_DB to a PostgreSQL connection string with permission to create tables in a dedicated empty database. Each example uses EnsureCreatedAsync or whole-model creation; run each against its own database.
using Microsoft.EntityFrameworkCore;
using DKNet.EfCore.Relational.Helpers;
var connectionString = Environment.GetEnvironmentVariable("DKNET_DOCS_DB")
?? throw new InvalidOperationException("Set DKNET_DOCS_DB to an empty PostgreSQL database.");
var o = new DbContextOptionsBuilder<DemoDb>();
o.UseNpgsql(connectionString);
await using var db = new DemoDb(o.Options);
await db.Database.EnsureCreatedAsync();
Console.WriteLine(await db.TableExistsAsync<Item>()); // True
public sealed class DemoDb(DbContextOptions<DemoDb> options) : DbContext(options)
{
public DbSet<Item> Items => Set<Item>();
}
public sealed class Item
{
public int Id { get; set; }
public string Name { get; set; } = "";
}
The scalar query names its projected column Value for EF composition and uses SingleAsync with the caller cancellation token. It does not query entity rows.