using Microsoft.EntityFrameworkCore; using PermissionManagement.Api.DDD.Domain.Entites; namespace PermissionManagement.Api.EF; public class PermissionManagementContext : DbContext { public PermissionManagementContext(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=PermissionManagement;user id=root;password=pwd123456", 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.PermissionName).HasComment("权限名称"); entity.Property(e => e.ProviderKey).HasComment("角色或者用户Id"); entity.Property(e => e.ProviderName).HasComment("提供者名称"); }); } }