我有一个包含三个数据库的旧系统
I have a legacy system with three databases
Vendor 包含来自我们的 Vendors 应用的控制和日志数据.
Vendor contains control and log data from our Vendors app.
CustomCode 包含许多连接到 Vendor 和 LogData 的视图和存储过程
CustomCode contains lots of views and stored procedures that joins to Vendor and LogData
LogData 包含来自我们的 CustomCode 流程的结果.例如:每日/每周/每月总结和结果.
LogData contains results from our CustomCode processes. eg: Daily/Weekly/Monthly summaries and results.
我正在编写一个在地图上绘制数据的网站.单位列表来自 CustomCode 中的视图.摘要记录来自 LogData,各个日志点通过 CustomCode 中的存储过程从 Vendor 检索.
I'm writing a website that will plot data on a map. The list of units is from a view in CustomCode. The Summary record is from LogData, and the individual log points are retrieved from Vendor by a stored proc in CustomCode.
我从 CustomCode 的 DbContext 开始,但似乎无法导航到第二个 DbContext 中的属性到 LogData
I started with a DbContext for CustomCode, but can't seem to Navigate to properties in a 2nd DbContext to LogData
我可以在不同上下文的对象之间链接导航属性吗?
Can I link navigation properties between objects in different contexts?
我可以一次连接多个数据库的上下文吗?
Can I have once context with multiple databases connected ?
请注意,这与多租户或多架构无关
Please note, this is nothing to do with multi-tenant or multi-schema
推荐答案我可以在不同上下文的对象之间链接导航属性吗?
Can I link navigation properties between objects in different contexts?
没有
我可以在一个上下文中连接多个数据库吗?
Can I have one context with multiple databases connected?
没有
建议:
如果数据库可以相互通信(即在同一台服务器上),这似乎自
If the databases can communicate to each other (ie on same server), which appears to be already done since
CustomCode 包含许多连接到 Vendor 和 LogData 的视图和存储过程
CustomCode contains lots of views and stored procedures that joins to Vendor and LogData
然后创建一个存储过程来执行所需的查询(可以连接来自不同数据库的表).
then create a stored procedure to perform the desired queries (which can join tables from separate databases).
从那里您应该能够从实体框架公开和执行过程以执行所需的功能.
From there you should be able to expose and execute the procedure from Entity Framework to perform the desired functionality.
这将避免有多个上下文并试图将数据连接到内存中,如果数据集很大,这可能会产生不利影响.
This would avoid have multiple contexts and trying to join the data in memory, which can have adverse effects if the data set is large.
更多推荐
EF Core 和多个数据库
发布评论