public DemoDbContext CreateDbContext(string[] args)
        {
            var builder       = new DbContextOptionsBuilder <DemoDbContext>();
            var configuration = AppConfigurations.Get(WebContentDirectoryFinder.CalculateContentRootFolder());

            DemoDbContextConfigurer.Configure(builder, configuration.GetConnectionString(DemoConsts.ConnectionStringName));

            return(new DemoDbContext(builder.Options));
        }
示例#2
0
文件: Class1.cs 项目: kazemim99/Demo
        public DemoDbContext CreateDbContext(string[] args)
        {
            var builder       = new DbContextOptionsBuilder <DemoDbContext>();
            var configuration = AppConfigurations.Get(
                WebContentDirectoryFinder.CalculateContentRootFolder(),
                addUserSecrets: true
                );

            DemoDbContextConfigurer.Configure(builder, configuration.GetConnectionString("Default"));

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