前往新版Gitcode,体验更适合开发者的 AI 搜索 >>
using Aurora.Common.Entities; using Microsoft.EntityFrameworkCore; using Microsoft.EntityFrameworkCore.Metadata.Builders; using System; namespace Aurora.Core.EntityFramework.EntitiesConfig { /// <summary> /// 对父类领域实体配置 /// </summary> /// <typeparam name="T"></typeparam> public abstract class BaseEntityTypeConfiguration<T> : IEntityTypeConfiguration<T> where T : class, ITenantEntity { public void Configure(EntityTypeBuilder<T> builder) { builder.Property(x => x.TenantCode).HasMaxLength(100); builder.HasKey(x => new { x.TenantCode, x.ID }); // builder.HasIndex(x => new { x.TenantCode, x.ID }); // builder.Property(x => x.RowCreatedBy).HasMaxLength(100); // builder.Property(x => x.RowUpdatedBy).HasMaxLength(100); Map(builder); } /// <summary> /// 强行让子类实现自己配置 /// </summary> /// <param name="builder"></param> public abstract void Map(EntityTypeBuilder<T> builder); } }