using Microsoft.EntityFrameworkCore; using Microsoft.EntityFrameworkCore.Metadata.Builders; namespace Prefab.Data.Configs { /// /// Base configuration for all entities, sets items like table name and schema. /// /// The entity type. public abstract class EntityConfig : IEntityTypeConfiguration where T : class { private readonly string _schema; private readonly string _tableName; protected EntityConfig(string tableName, string? schema = null) { ArgumentException.ThrowIfNullOrWhiteSpace(tableName); _tableName = tableName; _schema = string.IsNullOrWhiteSpace(schema) ? "dbo" : schema; } public virtual void Configure(EntityTypeBuilder builder) { builder.ToTable(_tableName, _schema); } } }