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

            BreedDbContextConfigurer.Configure(builder, configuration.GetConnectionString(BreedConsts.ConnectionStringName));

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

            // Set this setting to true for enabling entity history.
            Configuration.EntityHistory.IsEnabled = false;

            // Uncomment below line to write change logs for the entities below:
            // Configuration.EntityHistory.Selectors.Add("BreedEntities", EntityHistoryHelper.TrackedTypes);
            // Configuration.CustomConfigProviders.Add(new EntityHistoryConfigProvider(Configuration));
        }