1. <i id='jbgsB'><tr id='jbgsB'><dt id='jbgsB'><q id='jbgsB'><span id='jbgsB'><b id='jbgsB'><form id='jbgsB'><ins id='jbgsB'></ins><ul id='jbgsB'></ul><sub id='jbgsB'></sub></form><legend id='jbgsB'></legend><bdo id='jbgsB'><pre id='jbgsB'><center id='jbgsB'></center></pre></bdo></b><th id='jbgsB'></th></span></q></dt></tr></i><div id='jbgsB'><tfoot id='jbgsB'></tfoot><dl id='jbgsB'><fieldset id='jbgsB'></fieldset></dl></div>
        <tfoot id='jbgsB'></tfoot>

        • <bdo id='jbgsB'></bdo><ul id='jbgsB'></ul>
        <legend id='jbgsB'><style id='jbgsB'><dir id='jbgsB'><q id='jbgsB'></q></dir></style></legend>

        <small id='jbgsB'></small><noframes id='jbgsB'>

        使实体框架模型跨越多个数据库

        Making an Entity Framework Model span multiple databases(使实体框架模型跨越多个数据库)
        <legend id='iheKz'><style id='iheKz'><dir id='iheKz'><q id='iheKz'></q></dir></style></legend>

        <i id='iheKz'><tr id='iheKz'><dt id='iheKz'><q id='iheKz'><span id='iheKz'><b id='iheKz'><form id='iheKz'><ins id='iheKz'></ins><ul id='iheKz'></ul><sub id='iheKz'></sub></form><legend id='iheKz'></legend><bdo id='iheKz'><pre id='iheKz'><center id='iheKz'></center></pre></bdo></b><th id='iheKz'></th></span></q></dt></tr></i><div id='iheKz'><tfoot id='iheKz'></tfoot><dl id='iheKz'><fieldset id='iheKz'></fieldset></dl></div>

          • <bdo id='iheKz'></bdo><ul id='iheKz'></ul>
              <tbody id='iheKz'></tbody>

              <small id='iheKz'></small><noframes id='iheKz'>

                  <tfoot id='iheKz'></tfoot>
                • 本文介绍了使实体框架模型跨越多个数据库的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着跟版网的小编来一起学习吧!

                  问题描述

                  做诸如

                  CREATE SYNONYM [dbo].[MyTable] FOR [AnotherDatabase].dbo.[MyTable]

                  然后修改实体框架的 edmx 文件以像读取任何其他表一样读取此对象?

                  and then modify Entity Framework's edmx file to read this object like it would any other table?

                  我做了一个快速的示例测试,它似乎可以很好地进行选择和更新,但我想知道是否有任何理由为什么我不应该这样做

                  I did a quick sample test and it seems to work fine for selecting and updating, but I wanted to know if there was any reason why I shouldn't be doing this

                  我通过创建一个指向第二个数据库的 edmx 文件来获取表定义,在那里构建实体,然后将定义复制/粘贴到第一个数据库的 edmx 文件中.

                  I am getting the table definition by creating an edmx file pointing to the 2nd database, building out the entities there, then copy/pasting the definition into the 1st database's edmx file.

                  更新

                  如果有人感兴趣,我写了我做了什么使 edmx 文件跨越多个数据库 此处.它包括用于生成同义词和合并 edmx 文件的脚本.

                  If anyone is interested, I wrote up what I did to make an edmx file span mulitple databases here. It includes scripts for generating synonyms and merging edmx files.

                  推荐答案

                  如果你做了一个测试并且它有效,你可能展示了一些其他人不知道的东西.直到现在我总是回答这种类型的问题:不可能对两个数据库使用单个模型(基于视图隐藏第二个数据库中的表的一些更丑陋的解决方法).现在我知道两种解决方法.

                  If you made a test and it worked you probably showed something nobody else know about. Till now I always answered this type of question: It is not possible to use single model with two databases (with some more ugly workaround based on views hiding tables from the second database). Now I know two workarounds.

                  这种方法的唯一缺点是,如果您运行从数据库更新模型,那么手动对 EDMX 的 SSDL 部分所做的所有更改都会丢失.这意味着要么手动开发 EDMX(这是一项非常艰巨的工作),要么使用一些工具/脚本在每次更新数据库后添加您的更改.

                  The only disadvantage of this approach is that all changes made manually to SSDL part of your EDMX are always lost if you run Update model from database. This means either manual development of EDMX (which is quite hard work) or using some tool / script which will add your changes after each update from database.

                  这篇关于使实体框架模型跨越多个数据库的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持跟版网!

                  本站部分内容来源互联网,如果有图片或者内容侵犯了您的权益,请联系我们,我们会在确认后第一时间进行删除!

                  相关文档推荐

                  Building a comma separated list?(建立一个逗号分隔的列表?)
                  Errors in SQL Server while importing CSV file despite varchar(MAX) being used for each column(尽管每列都使用了 varchar(MAX),但在导入 CSV 文件时 SQL Server 中出现错误)
                  How can I import an Excel file into SQL Server?(如何将 Excel 文件导入 SQL Server?)
                  Export table to file with column headers (column names) using the bcp utility and SQL Server 2008(使用 bcp 实用程序和 SQL Server 2008 将表导出到带有列标题(列名称)的文件)
                  Concat field value to string in SQL Server(将字段值连接到 SQL Server 中的字符串)
                  SQL Server Bulk insert of CSV file with inconsistent quotes(SQL Server 批量插入带有不一致引号的 CSV 文件)

                  • <small id='uhVRg'></small><noframes id='uhVRg'>

                        <i id='uhVRg'><tr id='uhVRg'><dt id='uhVRg'><q id='uhVRg'><span id='uhVRg'><b id='uhVRg'><form id='uhVRg'><ins id='uhVRg'></ins><ul id='uhVRg'></ul><sub id='uhVRg'></sub></form><legend id='uhVRg'></legend><bdo id='uhVRg'><pre id='uhVRg'><center id='uhVRg'></center></pre></bdo></b><th id='uhVRg'></th></span></q></dt></tr></i><div id='uhVRg'><tfoot id='uhVRg'></tfoot><dl id='uhVRg'><fieldset id='uhVRg'></fieldset></dl></div>
                          <bdo id='uhVRg'></bdo><ul id='uhVRg'></ul>

                            <tfoot id='uhVRg'></tfoot>

                          1. <legend id='uhVRg'><style id='uhVRg'><dir id='uhVRg'><q id='uhVRg'></q></dir></style></legend>
                              <tbody id='uhVRg'></tbody>