У меня есть разные DbContext, которые имеют разные таблицы в одной базе данных. Таблицы имеют имя схемы после DbContext.
В DbContextOne у меня есть модель App, на которую ссылаются многие другие таблицы, но как могу ли я включить приложение в запросы к моделям в другом DbContext?
Код: Выделить всё
DbContextOne:
{
public DbSet Client { get; set; }
public DbSet App { get; set; }
}
Код: Выделить всё
DbContextTwo:
{
public DbSet WebSite { get; set; }
public DbSet View { get; set; }
}
Код: Выделить всё
WebSite
Код: Выделить всё
public class WebSite : DbSecureKey, IWebSite
{
public int AppId { get; set; }
public string Title { get; set; }
public string? TitleSeparator { get; set; } = null;
public string? BaseUrl { get; set; } = null;
}
Код: Выделить всё
context.GetWorker().DbSet
.Include(st => st.App)
.ThenInclude(app => app.Client)
.Include(st => st.Options)
.Include(st => st.Cultures)
.ThenInclude(clt => clt.Culture);
Подробнее здесь: https://stackoverflow.com/questions/792 ... ework-core