I have a .net core app using entity framework core. When running entity framework migrations or updates via the command line, I get a "value cannot be null. Parameter name: connectionString"
The connection string is kept as an environment variable:
ConnectionStrings__SomeContextConnection ...(localdb)\\MSSQLLocalDB...
However, when I move that exact same connection string into a .json config file:
"ConnectionStrings": {
"SomeContextConnection": "...(localdb)\\MSSQLLocalDB..."
}
Then the entity framework tools recognize the connection string without issue. When debugging the code, in Startup.cs:
var connectionString = _config.GetConnectionString("SomeContextConnection");
the connectionString variable is set to the correct string when the string is stored in either of the two locations, but it crashes when trying to connect to the database when using the environment var.
(note: in the environment variable case, the connection string is escaped so goes from
(localdb)\\MSSQLLocalDB...
to
(localdb)\\\\MSSQLLocalDB...
but the issue persists even after removing the extra back-slashes)
UPDATE: When the connection string is moved into a Windows level environment variable, it works fine. Seems to only be an issue when using Visual Studio environment variables.