public EmsDbContext CreateDbContext(string[] args)
        {
            var builder       = new DbContextOptionsBuilder <EmsDbContext>();
            var configuration = AppConfigurations.Get(WebContentDirectoryFinder.CalculateContentRootFolder(), addUserSecrets: true);

            EmsDbContextConfigurer.Configure(builder, configuration.GetConnectionString(EmsConsts.ConnectionStringName));

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

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