Entity Framework Core migration – connection string

I'm having a problem to handle the DB connection string in conjunction with migrations. I have 2 projects:

  • Domain
  • Application

The DbContext is in the Domain project, so this is the project I run migrations against. The migrations concept enforces me to implement OnConfiguring in my DbContext and therein specify the database provider, eg:

protected override void OnConfiguring(DbContextOptionsBuilder builder)
{
    builder.UseSqlServer("<connection string>");
}

My problem is that I don't want to use a hard coded connection string, for obvious reasons, and I cannot use ConfigurationManager to read it from the config file since the config file is in the application project.



Read more here: https://stackoverflow.com/questions/47473277/entity-framework-core-migration-connection-string

Content Attribution

This content was originally published by Robert at Recent Questions - Stack Overflow, and is syndicated here via their RSS feed. You can read the original post over there.

%d bloggers like this: