Skip to content

Instantly share code, notes, and snippets.

Embed
What would you like to do?
public static FleetContext Create(string tenantSchema, DbConnection connection)
{
Database.SetInitializer(null);
DbCompiledModel compiledModel = modelCache.GetOrAdd(
Tuple.Create(connection.ConnectionString, tenantSchema),
t = =>
{
DbModelBuilder builder = new DbModelBuilder();
builder.Conventions.Remove();
builder.Configurations.Add(new CarMap(tenantSchema));
builder.Configurations.Add(new ModelsMap(tenantSchema));
builder.Configurations.Add(new PersonsMap(tenantSchema));
builder.Configurations.Add(new ManufacturerMap(tenantSchema));
builder.Configurations.Add(new ContractsMap(tenantSchema));
builder.Configurations.Add(new CustomersMap(tenantSchema));
builder.Configurations.Add(new InsurersMap(tenantSchema));
builder.Configurations.Add(new VehiclesMap(tenantSchema));
builder.Configurations.Add(new LogMap(tenantSchema));
var model = builder.Build(connection);
return model.Compile();
});
return new FleetContext(connection, compiledModel);
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
You can’t perform that action at this time.