I have declared my own DbContext:
public class DbContextMain: DbContext
{
// some DbSets here
public DbContextMain(): base()
{
}
protected override void OnConfiguring(DbContextOptionsBuilder optionsBuilder)
{ optionsBuilder.UseNpgsql("Host=myip;Username=postgres;Password=postgres;Database=test");
}
}
Please note, that is being configured to use Database=test
But when I run the following code inside another console project:
static void Main(string[] args) {
DbContextMain dbContextMain = new();
dbContextMain.Database.Migrate();
}
I get strange exception:
Npgsql.PostgresException: "3D000: database "postgres" does not exist"
Please note, that database mentioned in exception is "postgres" while my database is "test" (and I double checked - method OnConfiguring is executed before Migrate call)
What I do wrong?