Database 最好使用两个连接字符串或使用链接服务器
我有一个ASP.NET核心的web应用程序,目前有两个连接字符串,连接到两个不同的服务器。用户将在字段中输入一个值,它将查询连接字符串Database 最好使用两个连接字符串或使用链接服务器,database,asp.net-core,connection-string,linked-server,Database,Asp.net Core,Connection String,Linked Server,我有一个ASP.NET核心的web应用程序,目前有两个连接字符串,连接到两个不同的服务器。用户将在字段中输入一个值,它将查询连接字符串获取,返回结果,并添加到连接字符串\u上下文 //my two connection strings are 'fetch' and '_context' public ActionResult FetchData(string name) { var result = fetch.TAbleName.FirstOrDefault(x => x.Na
获取
,返回结果,并添加到连接字符串\u上下文
//my two connection strings are 'fetch' and '_context'
public ActionResult FetchData(string name)
{
var result = fetch.TAbleName.FirstOrDefault(x => x.Name == name);
//Here the object is serialized, then deserialized into an entity for my other database, then is added
_context.Add(result);
_context.Update();
}
基本上,我使用fetch
连接字符串来查询结果,然后使用\u context
来查询实际的站点连接字符串,以及将要使用和添加到视图中的所有内容。我只使用fetch
,来检索数据并将其导入\u上下文
//my two connection strings are 'fetch' and '_context'
public ActionResult FetchData(string name)
{
var result = fetch.TAbleName.FirstOrDefault(x => x.Name == name);
//Here the object is serialized, then deserialized into an entity for my other database, then is added
_context.Add(result);
_context.Update();
}
我的问题是,我应该为此使用两个不同的连接字符串,还是应该只使用\u context
并使用Linked Server查询结果