Open DesertMountSolution opened 1 year ago
I need to set connection string in constructor.
public MultiTenantStoreDbContext(DbContextOptions<MultiTenantStoreDbContext> options,
IConfiguration configuration) : base(options)
{
_configuration = configuration;
var connectionString = _configuration.GetConnectionString("MultiTenant");
Database.SetConnectionString(connectionString);
}
hi @DesertMountSolution
I'm not familiar with using server version and autodetect like you have here:
var connectionString = _configuration.GetConnectionString("MultiTenant");
var serverVersion = ServerVersion.AutoDetect(connectionString);
optionsBuilder.UseMySql(serverVersion);
Does UseMySql
not just accept the connection string as normal?
There's nothing special about EFCoreStoreDbContext<TenantInfo>
in how it connects to a database. The usual approach of assigning the provider and connection string wither in the service setup or in OnConfiguring
should work just like any other db context.
Can not connect to database.
Register
EfContext
Try to resolve tenant store
GetAllAsync throws an exception with "A relational store has been configured without specifying either the DbConnection or connection string to use."