UPD here is the way I solved the problem. Although it\'s likely to be not the best one, it worked for me.
I have an issue with working with EF
There are a couple ways to do this:
DbContextOptionsBuilder.UseModel()
IModelCacheKeyFactory