c# - EF Core Migrations with Multiple DB Schemas -


ef core 1.1 , sql server 2016

we running microservice application microservices having independent few tables. 1 of solutions have many tables individual microservice, give these services unique schema (e.g. not dbo) , put of them in 1 database (good cost + maintenance).

that works fine in ef 6, however, looking @ generated dbo.__efmigrationshistory in core, looks core doesn't take schema account.

i aware migration in ef core has changed in code rather db, problem version recorded in dbo.__efmigrationshistory table schema-agnostic.

do know how can make ef core schema-aware when writes migration db?

n.b. builder.hasdefaultschema(constants.schema); set in dbcontext.

builder.hasdefaultschema() used set schema model. migrationhistory table configured bit differently. can read more here

from link,

the simplest scenario when want change table name or schema. can done using migrationshistorytable method in onconfiguring (or configureservices on asp.net core). here example.

protected override void onconfiguring(dbcontextoptionsbuilder options)     => options.usesqlserver(         connectionstring,         x => x.migrationshistorytable("__mymigrationshistory", "myschema")); 

Comments

Popular posts from this blog

ZeroMQ on Windows, with Qt Creator -

unity3d - Unity SceneManager.LoadScene quits application -

python - Error while using APScheduler: 'NoneType' object has no attribute 'now' -