0

我尝试了以下代码:

CrmEfEntities dc = new CrmEfEntities(federatedRootDBConnectionString);
string federationCmdText = @"USE FEDERATION Customer_Test_Federation (testId=100) WITH FILTERING=ON, RESET";
dc.ExecuteStoreCommand(federationCmdText);  
var count = dc.Projects.Count();

我收到异常消息 - {"Invalid object name 'dbo.Project'."} 它连接到联合根数据库。执行了联合 sql 命令。但我没有得到实体对象。我正在使用 EntityFramework 4.0 。有人知道这个吗?

4

1 回答 1

3

您必须在 USE FEDERATION 命令之前打开连接

using (DemoEntities db = new DemoEntities())
{
   db.Connection.Open();
   string federationCmdText = @"USE FEDERATION ProdutosFed(ID = 110) WITH RESET, FILTERING=OFF";
   db.ExecuteStoreCommand(federationCmdText); 
}
于 2012-09-26T12:05:50.327 回答