We have different DB users (with differing permissions) that we use for read/write operations (readwrite) and for creating/modifying tables (modifytable).
I want to use a connection string with readwrite user for the DbContext class and was able to do it this way in the Program.cs file:
builder.Services.AddDbContext<ReadWriteContext>(
options => options.UseSqlServer(rwConnString));
How do I do the equivalent for the migrations part (i.e., giving it a connection string with the user modifytable)?
All the examples I've seen simply talk about running the following command in NuGet Package Manager Console:
Add-Migration InitialCreate
and then
Update-Database
How (& from where) does this Update-Database pick up the connection string? How do I supply a custom connection string?
We construct the connection string using some logic that takes some values from Azure Key Vault, so reading it from a configuration file is not an option.
I'm brand new to EF.
Found out the solution to my problem: the
Update-Databasecommand takes a connection string: