0

I'm using entityframework 6.2.0, and I'm on a multi-tenant architecture, I have to change the schema every time I change the country. in the 1st access to the application I point to the correct schema, on the other hand if I change the country entityframework does not change the default schema because it calls OnModelCreating only once. enter image description here

I made a method to force the call to OnModelCreating but I couldn't find how to delete the old modelBuilder.configuration first.

do you have any idea on how i can change the schema each time i change the country please ?

I found similar questions, but I couldn't find an answer to my question.

  • Side note: `I have to change the schema every time I change the country` - Do you also start a new instance with every change of country or maintain a (new) instance per country? Personally I would not try to use a single instance and have it switch schemas when the country switches... – Igor Jul 29 '22 at 12:12
  • thanks igor . did you mean thant i have to instantiate a new ContainerBuilder in global.asax every time i change the country? like this : ContainerBuilder builder = new ContainerBuilder(); builder.RegisterType().As().InstancePerRequest(); builder.RegisterType().As().WithParameter((pi, c) => pi.Name == "connectionString", (pi, c) => c.Resolve().GetConnectionStringName()).InstancePerRequest(); IContainer container = builder.Build(); – Kamal Benbrahim Jul 29 '22 at 16:25

0 Answers0