I changed my appSettings.config to no longer have connection strings as they are now all in Azure Key Vault. I was able to connect no problem, but now when I try to create the db using EF code first migrations in a new azure db using
add-migration InitialCreate
Value cannot be null.
Parameter name: connectionString
I am getting the error:
public Startup(IHostingEnvironment env)
{
AutomapperConfiguration.Configure();
_hostingEnvironment = env;
var builder = new ConfigurationBuilder()
.SetBasePath(env.ContentRootPath)
.AddJsonFile("appsettings.json", false, true)
.AddJsonFile($"appsettings.{env.EnvironmentName}.json", true)
.AddEnvironmentVariables();
if (env.EnvironmentName == Constant.EnvironmentName_QA || env.EnvironmentName == Constant.EnvironmentName_Staging || env.EnvironmentName == Constant.EnvironmentName_Production)
env.ConfigureNLog($"nlog.{env.EnvironmentName}.config");
else
env.ConfigureNLog($"nlog.config");
builder.AddAzureKeyVault(Configuration["AzureVault:Vault"], Configuration["AzureVault:ClientId"], Configuration["AzureVault:ClientSecret"]);
Configuration = builder.Build();
}
Configuration(){
.
.
.
services.AddDbContext<SafeContext>(options => options.UseSqlServer(Configuration[Configuration["AzureVaultKeys:DBConnectionString"]]));
.
.
.
}
