예제 #1
0
 protected override void OnConfiguring(DbContextOptionsBuilder optionsBuilder)
 {
     if (!optionsBuilder.IsConfigured)
     {
         IConfigurationRoot configuration = new ConfigurationBuilder()
                                            .SetBasePath(Directory.GetCurrentDirectory())
                                            .AddJsonFile("appsettings.json")
                                            .AddEnvironmentVariables()
                                            .Build();
         string connectionString = DatabaseTools.GetConnectionString(configuration);
         optionsBuilder.UseSqlServer(connectionString);
     }
 }