예제 #1
0
        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
        }
예제 #2
0
        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();
        }
예제 #3
0
        /// <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();
        }