示例#1
0
        public MMHDemoDbContext CreateDbContext(string[] args)
        {
            var builder       = new DbContextOptionsBuilder <MMHDemoDbContext>();
            var configuration = AppConfigurations.Get(WebContentDirectoryFinder.CalculateContentRootFolder(), addUserSecrets: true);

            MMHDemoDbContextConfigurer.Configure(builder, configuration.GetConnectionString(MMHDemoConsts.ConnectionStringName));

            return(new MMHDemoDbContext(builder.Options));
        }
示例#2
0
        public override void PreInitialize()
        {
            if (!SkipDbContextRegistration)
            {
                Configuration.Modules.AbpEfCore().AddDbContext <MMHDemoDbContext>(options =>
                {
                    if (options.ExistingConnection != null)
                    {
                        MMHDemoDbContextConfigurer.Configure(options.DbContextOptions, options.ExistingConnection);
                    }
                    else
                    {
                        MMHDemoDbContextConfigurer.Configure(options.DbContextOptions, options.ConnectionString);
                    }
                });
            }

            // Uncomment below line to write change logs for the entities below:
            // Because of https://github.com/aspnetboilerplate/aspnetboilerplate/issues/4948, below configuration will not work
            // Just add [Audited] attribute to Entities you want to enabled EntityHistory for until ABP 4.11 is released.
            //Configuration.EntityHistory.Selectors.Add("MMHDemoEntities", EntityHistoryHelper.TrackedTypes);
            //Configuration.CustomConfigProviders.Add(new EntityHistoryConfigProvider(Configuration));
        }