Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Adding a 'profile' parameter to ef migrations add and ef migrations update #22190

Closed
pdevito3 opened this issue Aug 24, 2020 · 6 comments
Closed

Comments

@pdevito3
Copy link

Currently, when working on a project with multiple appsettings.{environment}.json files, there is no way to add a migration or update the database while pointing to a particular profile.

So say I have a project with two the appsetting files below. When I try to add a migration or update the database after the fact, there is no way for me to tell the CLI where to look at.

So let's say I have appsettings.Production.json:

{
  "UseInMemoryDatabase": false,
  "ConnectionStrings": {
    "HelloDb": "Data Source=localhost\\SqlExpress;Initial Catalog=MyDbName;Integrated Security=True;Encrypt=True;TrustServerCertificate=True;"
  },
  "Logging": {
    "LogLevel": {
      "Default": "Information",
      "Microsoft": "Warning",
      "Microsoft.Hosting.Lifetime": "Information"
    }
  },
  "AllowedHosts": "*"
}

and I have appsettings.Development.json:

{
  "UseInMemoryDatabase": true,
  "Logging": {
    "LogLevel": {
      "Default": "Information",
      "Microsoft": "Warning",
      "Microsoft.Hosting.Lifetime": "Information"
    }
  },
  "AllowedHosts": "*"
}

Similar to how dotnet run has a launch profile option, it would be really useful to have that option on the ef migrations add and ef migrations update commands

@bricelam
Copy link
Contributor

Needs #8695

@bricelam
Copy link
Contributor

Note, you can currently set ASPNETCORE_ENVIRONMENT before running dotnet ef to let the host builder locate the appropriate settings file.

@pdevito3
Copy link
Author

Thanks @bricelam found that work around this morning. Not really an ideal workflow, but will work for now. Seems like an update is on the horizon though in EF5? Is there any kind of estimated timeline for that?

@bricelam
Copy link
Contributor

No significant updates around this issue specifically in 5.0.0, but that version will be released at www.dotnetconf.net in November.

@ajcvickers
Copy link
Member

Closing in favor of #8695

@saliksaly
Copy link

It is possible to implement IDesignTimeDbContextFactory which can then read connection string from appsettings.Development.json.
Here is how:

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
Development

No branches or pull requests

4 participants