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

            BukStoreDbContextConfigurer.Configure(builder, configuration.GetConnectionString(BukStoreConsts.ConnectionStringName));

            return(new BukStoreDbContext(builder.Options));
        }
示例#2
0
        public override void PreInitialize()
        {
            if (!SkipDbContextRegistration)
            {
                Configuration.Modules.AbpEfCore().AddDbContext <BukStoreDbContext>(options =>
                {
                    if (options.ExistingConnection != null)
                    {
                        BukStoreDbContextConfigurer.Configure(options.DbContextOptions, options.ExistingConnection);
                    }
                    else
                    {
                        BukStoreDbContextConfigurer.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("BukStoreEntities", EntityHistoryHelper.TrackedTypes);
            // Configuration.CustomConfigProviders.Add(new EntityHistoryConfigProvider(Configuration));
        }