这是我的NPGSQL连接字符串
{
"ConnectionStrings": {
"DataAccessPostgreSqlProvider": "User ID=damienbod;Password=1234;Host=localhost;Port=5432;Database=damienbod;Pooling=true;"
}
}
}
Run Code Online (Sandbox Code Playgroud)
取自这里:https : //damienbod.com/2016/01/11/asp-net-5-with-postgresql-and-entity-framework-7/
但是我schemas在我的Postgres数据库下使用。如何连接到idsrv4架构?
您还可以在连接字符串中指定搜索路径:
{
"ConnectionStrings": {
"DataAccessPostgreSqlProvider": "User ID=damienbod;Password=1234;Host=localhost;Port=5432;Database=damienbod;Pooling=true;SearchPath=your_search_path;"
}
}
Run Code Online (Sandbox Code Playgroud)
所有模式都位于同一数据库下,因此当您连接到该数据库时,您可以访问所有模式。如果要访问idsrv4架构中的表,只需限定其名称:
SELECT * FROM idsrv4.mytable;
Run Code Online (Sandbox Code Playgroud)
如果您不想使用架构限定表名的所有实例,您可以更改该search_path变量:
SET search_path = 'idsrv4,public';
Run Code Online (Sandbox Code Playgroud)
现在对于此连接的其余部分,您可以执行SELECT * FROM mytable. 的含义search_path是,它包含指定非限定表名时要搜索的模式列表。Notesearch_path在每次连接的基础上工作,因此每次连接到数据库时都必须设置它。
| 归档时间: |
|
| 查看次数: |
7502 次 |
| 最近记录: |