mergfe
This commit is contained in:
commit
52eb48f3fe
2
.gitignore
vendored
2
.gitignore
vendored
@ -361,6 +361,6 @@ MigrationBackup/
|
|||||||
|
|
||||||
# Fody - auto-generated XML schema
|
# Fody - auto-generated XML schema
|
||||||
FodyWeavers.xsd
|
FodyWeavers.xsd
|
||||||
/.vs/ApiPolo/DesignTimeBuild/.dtbcache.v2
|
|
||||||
/.vs/ApiPolo/v17/.suo
|
/.vs/ApiPolo/v17/.suo
|
||||||
/.vs/ApiPolo/v17/.futdcache.v2
|
/.vs/ApiPolo/v17/.futdcache.v2
|
||||||
|
/.vs/ApiPolo/DesignTimeBuild/.dtbcache.v2
|
||||||
|
|||||||
@ -14,16 +14,15 @@ public class TenantDbContextFactory : ITenantDbContextFactory
|
|||||||
public ITenantDbContext GetDbContext(string tenant)
|
public ITenantDbContext GetDbContext(string tenant)
|
||||||
{
|
{
|
||||||
// Create a scope to resolve DbContext
|
// Create a scope to resolve DbContext
|
||||||
using (var scope = _serviceProvider.CreateScope())
|
var scope = _serviceProvider.CreateScope();
|
||||||
|
|
||||||
|
return tenant switch
|
||||||
{
|
{
|
||||||
return tenant switch
|
Clienti.Maras => scope.ServiceProvider.GetRequiredService<Maras_DbContext>(),
|
||||||
{
|
Clienti.Marrocco => scope.ServiceProvider.GetRequiredService<Marro_DbContext>(),
|
||||||
Clienti.Maras => scope.ServiceProvider.GetRequiredService<Maras_DbContext>(),
|
// Add other tenants as needed
|
||||||
Clienti.Marrocco => scope.ServiceProvider.GetRequiredService<Marro_DbContext>(),
|
// Clienti.AnotherTenant => scope.ServiceProvider.GetRequiredService<AnotherTenant_DbContext>(),
|
||||||
// Add other tenants as needed
|
_ => throw new KeyNotFoundException($"No DbContext found for tenant: {tenant}")
|
||||||
// Clienti.AnotherTenant => scope.ServiceProvider.GetRequiredService<AnotherTenant_DbContext>(),
|
};
|
||||||
_ => throw new KeyNotFoundException($"No DbContext found for tenant: {tenant}")
|
|
||||||
};
|
|
||||||
}
|
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|||||||
Loading…
Reference in New Issue
Block a user