Warning: file_get_contents(/data/phpspider/zhask/data//catemap/1/database/8.json): failed to open stream: No such file or directory in /data/phpspider/zhask/libs/function.php on line 167

Warning: Invalid argument supplied for foreach() in /data/phpspider/zhask/libs/tag.function.php on line 1116

Notice: Undefined index: in /data/phpspider/zhask/libs/function.php on line 180

Warning: array_chunk() expects parameter 1 to be array, null given in /data/phpspider/zhask/libs/function.php on line 181
Database 最好使用两个连接字符串或使用链接服务器_Database_Asp.net Core_Connection String_Linked Server - Fatal编程技术网

Database 最好使用两个连接字符串或使用链接服务器

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

我有一个ASP.NET核心的web应用程序,目前有两个连接字符串,连接到两个不同的服务器。用户将在字段中输入一个值,它将查询连接字符串
获取
,返回结果,并添加到连接字符串
\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查询结果