Closed jimbo74 closed 7 years ago
Is there a stacktrace with the error?
Ok so, we're looking at this piece of code:
if (_connectionString != null)
{
Console.WriteLine("Using provided connection string as an override.");
dbMigrationsConfiguration.TargetDatabase = new DbConnectionInfo(_connectionString, _providerName);
}
The only reason that error would happen is if the connection string is all whitespace. That's weird.
This is a print of the command and error:
migrations list
for example)version 1.0.8
I get the same error with the other commands
Are you by any chance using localdb? Doesn't look like it, but now I remembered that in my tests localdb didn't work when you specify the connection string from the command line (so I used sqlexpress). Now, the error here is completely different anyway, it doesn't make much sense. The "_connectionString" variable is only every written to by the command line parser ("Microsoft.DotNet.Cli.Utils").
Would the same issue occur if you try with a fresh project (+ sqlexpress)? Because it's working fine on my machine (yeah I know).
I'm using a database on azure, I can try a new project with sqlexpress but that isn't my end goal so I don't see what I'll get from that.
Thanks for your help with this though
Problem is I can't think of something that might lead to this error. If @DOTang would be so kind to give his input. Are you still using this option (specifying the connection string in the command line)? If so is it working okay for you?
Yes I saw @DOTang was trying to do something similar which is what led me to this. Lets see what he says
I use the connection string in the command, I use a normal SQL DB, not express or azure though.
Hmm maybe the problem is related to Azure? I'm seeing the same expected behavior on my end.
I'm closing this, please reopen if you still have issues.
When trying to add a new migration passing in a connection string I get the above error.
My command is similar to: dotnet ef migrations add TestClassAdded --connection-string "Server=xxx;Database=yyy;etc.."
The tool compiles my project and then states:
Using provided connection string as an override. The argument 'nameOrConnectionString' cannot be null, empty or contain only white space.
I have successfully done the initial create (with connection string hard coded) and the update database following this (passing in the connection string) but now I get this strange result when trying to add another migration where it tells me it's using the connectionstring but then doesn't