using Microsoft.EntityFrameworkCore; using TenantManagement.Api.DDD.Domain.Entites; namespace TenantManagement.Api.EF { public partial class TenantManagementContext : DbContext { public TenantManagementContext() { } public TenantManagementContext(DbContextOptions options) : base(options) { } public virtual DbSet Tenant { get; set; } protected override void OnConfiguring(DbContextOptionsBuilder optionsBuilder) { if (!optionsBuilder.IsConfigured) { optionsBuilder.UseMySql("data source=127.0.0.1;initial catalog=TenantManagement;user id=root;password=pwd123456", Microsoft.EntityFrameworkCore.ServerVersion.Parse("8.0.28-mysql")); } } protected override void OnModelCreating(ModelBuilder modelBuilder) { modelBuilder.UseCollation("utf8mb4_0900_ai_ci") .HasCharSet("utf8mb4"); modelBuilder.Entity(entity => { entity.HasComment("租户表"); entity.Property(e => e.Id).HasComment("主键Id"); entity.Property(e => e.CreationTime).HasComment("创建时间"); entity.Property(e => e.TenantName).HasComment("租户名称"); }); } } }