Skip to content

Commit 15a6199

Browse files
authored
Merge pull request #606 from aspnetboilerplate/pr/6133
DB migration based on environment
2 parents 0d89487 + d1666c4 commit 15a6199

File tree

1 file changed

+7
-0
lines changed

1 file changed

+7
-0
lines changed

aspnet-core/src/AbpCompanyName.AbpProjectName.EntityFrameworkCore/EntityFrameworkCore/AbpProjectNameDbContextFactory.cs

Lines changed: 7 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -12,6 +12,13 @@ public class AbpProjectNameDbContextFactory : IDesignTimeDbContextFactory<AbpPro
1212
public AbpProjectNameDbContext CreateDbContext(string[] args)
1313
{
1414
var builder = new DbContextOptionsBuilder<AbpProjectNameDbContext>();
15+
16+
/*
17+
You can provide an environmentName parameter to the AppConfigurations.Get method.
18+
In this case, AppConfigurations will try to read appsettings.{environmentName}.json.
19+
Use Environment.GetEnvironmentVariable("ASPNETCORE_ENVIRONMENT") method or from string[] args to get environment if necessary.
20+
https://docs.microsoft.com/en-us/ef/core/cli/dbcontext-creation?tabs=dotnet-core-cli#args
21+
*/
1522
var configuration = AppConfigurations.Get(WebContentDirectoryFinder.CalculateContentRootFolder());
1623

1724
AbpProjectNameDbContextConfigurer.Configure(builder, configuration.GetConnectionString(AbpProjectNameConsts.ConnectionStringName));

0 commit comments

Comments
 (0)