protected override void OnModelCreating(ModelBuilder modelBuilder) { //modelBuilder.Entity<Role>(); //.Property(c => c.Enabled) //.HasConversion<int>(); foreach (var entityType in modelBuilder.Model.GetEntityTypes()) { foreach (var property in entityType.GetProperties()) { if (property.ClrType == typeof(bool)) { property.SetValueConverter(new BoolToIntConverter()); } } } base.OnModelCreating(modelBuilder); #if DEBUG //参考王如建写的,修改为支持.net core版本; var updater = new DbDescriptionUpdater <LeeAbpDbContext>(this); updater.UpdateDatabaseDescriptions(); #endif }
protected override void Seed(Quick.Models.DataContext context) { // This method will be called after migrating to the latest version. // You can use the DbSet<T>.AddOrUpdate() helper extension method // to avoid creating duplicate seed data. var updater = new DbDescriptionUpdater <DataContext>(context); updater.UpdateDatabaseDescriptions(); }
/// <summary> /// Seeds the database /// </summary> /// <param name="context">The context.</param> protected override void Seed(HelpDeskContext context) { var seeder = new Seeder(); SeedRoles(context, seeder.GetRoles()); SeedUsers(context, seeder.GetUsers()); SeedUserRoles(context, seeder.GetUserRoles()); // update descriptions DbDescriptionUpdater <HelpDeskContext> updater = new DbDescriptionUpdater <HelpDeskContext>(context); updater.UpdateDatabaseDescriptions(); }