Пример #1
0
        public ServiceDbContext CreateDbContext(string[] args)
        {
            var builder       = new DbContextOptionsBuilder <ServiceDbContext>();
            var configuration = AppConfigurations.Get(WebContentDirectoryFinder.CalculateContentRootFolder());

            ServiceDbContextConfigurer.Configure(builder, configuration.GetConnectionString(ServiceConsts.ConnectionStringName));

            return(new ServiceDbContext(builder.Options));
        }
Пример #2
0
        public override void PreInitialize()
        {
            // add this line to disable transactions for sqlite
            Configuration.UnitOfWork.IsTransactional = false;

            if (!SkipDbContextRegistration)
            {
                Configuration.Modules.AbpEfCore().AddDbContext <ServiceDbContext>(options =>
                {
                    if (options.ExistingConnection != null)
                    {
                        ServiceDbContextConfigurer.Configure(options.DbContextOptions, options.ExistingConnection);
                    }
                    else
                    {
                        ServiceDbContextConfigurer.Configure(options.DbContextOptions, options.ConnectionString);
                    }
                });
            }
        }