Muslim.ConfigureTable
10.0.1
dotnet add package Muslim.ConfigureTable --version 10.0.1
NuGet\Install-Package Muslim.ConfigureTable -Version 10.0.1
<PackageReference Include="Muslim.ConfigureTable" Version="10.0.1" />
<PackageVersion Include="Muslim.ConfigureTable" Version="10.0.1" />
<PackageReference Include="Muslim.ConfigureTable" />
paket add Muslim.ConfigureTable --version 10.0.1
#r "nuget: Muslim.ConfigureTable, 10.0.1"
#:package Muslim.ConfigureTable@10.0.1
#addin nuget:?package=Muslim.ConfigureTable&version=10.0.1
#tool nuget:?package=Muslim.ConfigureTable&version=10.0.1
Muslim.ConfigureTable
EF Core 10 table setup for entities built on Muslim.EntityAndDto. Every table gets the same defaults — table name, creation date, soft delete — and each entity keeps its own configuration next to it.
dotnet add package Muslim.ConfigureTable
Quick start
Put a nested Configuration class inside the entity and derive it from ConfigureTable<T>:
using Microsoft.EntityFrameworkCore;
using Muslim.ConfigureTable;
using Muslim.EntityAndDto.Entitys;
public class Product : Entity
{
public string Name { get; set; } = "";
public decimal Price { get; set; }
private class Configuration : ConfigureTable<Product>
{
protected override void ConfigureCustomizations()
{
Builder!.Property(x => x.Name).HasMaxLength(200).IsRequired();
Builder.Property(x => x.Price).HasPrecision(18, 2);
}
}
}
Then load every configuration in the assembly with one line in your DbContext:
public class ShopContext(DbContextOptions<ShopContext> options) : DbContext(options)
{
public DbSet<Product> Products => Set<Product>();
protected override void OnModelCreating(ModelBuilder modelBuilder)
{
DatabaseInitializer.CreateMigration(modelBuilder, typeof(Product).Assembly, nameof(ShopContext));
}
}
Register the context as usual and create migrations with the normal EF Core tools:
builder.Services.AddDbContext<ShopContext>(o => o.UseSqlServer(connectionString));
dotnet ef migrations add Initial
What every table gets
| Default | Result |
|---|---|
| Table name | the class name — Product |
CreatedDate |
filled by the database with GETUTCDATE() |
Id |
indexed |
IsDeleted |
required, defaults to false |
| Query filter | !IsDeleted — deleted rows are hidden from every query |
To include deleted rows in one query, use EF Core's IgnoreQueryFilters():
var all = await db.Products.IgnoreQueryFilters().ToListAsync();
Anything you set in ConfigureCustomizations() runs after the defaults, so you can change any of
them:
protected override void ConfigureCustomizations()
{
Builder!.ToTable("Products", "shop");
Builder.HasIndex(x => x.Name).IsUnique();
}
One assembly, several contexts
By default a configuration is applied to every context that loads the assembly. To limit it, add
[Context] with the context names:
public class AuditLog : Entity
{
public string Action { get; set; } = "";
[Context(nameof(LogContext))]
private class Configuration : ConfigureTable<AuditLog> { }
}
AuditLog is now mapped in LogContext only. Names are case-sensitive. [Context] with no names
excludes the configuration from every context.
Good to know
GETUTCDATE()is SQL Server. On another database, set the default yourself:Builder!.Property(x => x.CreatedDate).HasDefaultValueSql("CURRENT_TIMESTAMP");- Calling
HasQueryFilterin your configuration replaces the soft-delete filter. Keep!x.IsDeletedin your own filter if you still need it. - Only concrete classes that inherit
Entityand have a nested class namedConfigurationare picked up. The class can be private, and needs a parameterless constructor. CreateMigrationbuilds the EF Core model. It does not create migrations or the database.- Configurations are found by reflection, so this package is not suitable for trimming or Native AOT.
Related packages
| Package | Use it for |
|---|---|
| Muslim.EntityAndDto | Base entity and DTO classes |
Coding-agent guidance
When you build a project that uses this package, a short guide for AI coding agents is copied to
.agents/skills/muslim-configuretable/ at the root of your repository. Agents that read skills from
.agents/skills, such as Codex and GitHub Copilot in VS Code, use it to write correct code against
this package. Your own files and other skills are never touched, and nothing is deleted
automatically.
To turn it off, add this to your project or Directory.Build.props:
<PropertyGroup>
<MuslimConfigureTableGenerateSkill>false</MuslimConfigureTableGenerateSkill>
</PropertyGroup>
License
See LICENSE.txt.
| 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
- Microsoft.EntityFrameworkCore (>= 10.0.13)
- Microsoft.EntityFrameworkCore.Relational (>= 10.0.13)
- Muslim.AssemblyHelper (>= 3.0.0)
- Muslim.EntityAndDto (>= 10.0.1)
NuGet packages
This package is not used by any NuGet packages.
GitHub repositories
This package is not used by any popular GitHub repositories.