httpflow
httpflow copied to clipboard
Using connection string from appsettings.json in StartupSetup.
Hello everyone!
In StartupSetup the connection string is hard-coded. What if I want to use one from appsettings.json?
Is it ok if I'll add a parameter connectionString to your method:
public static void AddDbContext(this IServiceCollection services, string connectionString) =>
services.AddDbContext<AppDbContext>(options =>
options.UseSqlServer(connectionString));
And just pass the connection string as an argument from Startup?
services.AddDbContext(Configuration.GetConnectionString("DefaultConnection"));
Yes, I'll fix that unless someone beats me to it.