Postgresql .NET Core 3.1 Postgres连接字符串Docker
我正试图用postgres docker映像在docker上运行我的asp net核心web api。 它在-IIS上工作:Postgresql .NET Core 3.1 Postgres连接字符串Docker,postgresql,docker,asp.net-core,Postgresql,Docker,Asp.net Core,我正试图用postgres docker映像在docker上运行我的asp net核心web api。 它在-IIS上工作: “连接字符串”:“服务器=127.0.0.1;端口=5400;数据库=test;用户名=postgres;密码=test;” 它在IIS上工作正常(端口5400-docker正在映射到5432) 它不适用于Docker: Loaded '/app/bin/x64/Debug/netcoreapp3.1/Npgsql.EntityFrameworkCore.PostgreS
“连接字符串”:“服务器=127.0.0.1;端口=5400;数据库=test;用户名=postgres;密码=test;”
它在IIS上工作正常(端口5400-docker正在映射到5432)
它不适用于Docker:
Loaded '/app/bin/x64/Debug/netcoreapp3.1/Npgsql.EntityFrameworkCore.PostgreSQL.dll'. Cannot find or open the PDB file.
Loaded '/app/bin/x64/Debug/netcoreapp3.1/Microsoft.EntityFrameworkCore.SqlServer.dll'. Cannot find or open the PDB file.
Loaded '/app/bin/x64/Debug/netcoreapp3.1/Microsoft.EntityFrameworkCore.Abstractions.dll'. Cannot find or open the PDB file.
Loaded '/app/bin/x64/Debug/netcoreapp3.1/Npgsql.dll'. Cannot find or open the PDB file.
Loaded '/usr/share/dotnet/shared/Microsoft.NETCore.App/3.1.8/System.Net.Security.dll'. Cannot find or open the PDB file.
Loaded '/usr/share/dotnet/shared/Microsoft.NETCore.App/3.1.8/System.Data.Common.dll'. Cannot find or open the PDB file.
Loaded '/usr/share/dotnet/shared/Microsoft.NETCore.App/3.1.8/System.Transactions.Local.dll'. Cannot find or open the PDB file.
Loaded 'Anonymously Hosted DynamicMethods Assembly'.
Loaded '/usr/share/dotnet/shared/Microsoft.NETCore.App/3.1.8/System.Xml.ReaderWriter.dll'. Cannot find or open the PDB file.
Loaded '/usr/share/dotnet/shared/Microsoft.NETCore.App/3.1.8/System.Runtime.Numerics.dll'. Cannot find or open the PDB file.
Loaded '/usr/share/dotnet/shared/Microsoft.NETCore.App/3.1.8/System.Net.NetworkInformation.dll'. Cannot find or open the PDB file.
Loaded '/usr/share/dotnet/shared/Microsoft.NETCore.App/3.1.8/System.ComponentModel.Annotations.dll'. Cannot find or open the PDB file.
Loaded '/app/bin/x64/Debug/netcoreapp3.1/Validation.dll'. Symbols loaded.
Loaded '/usr/share/dotnet/shared/Microsoft.NETCore.App/3.1.8/System.Diagnostics.Debug.dll'. Cannot find or open the PDB file.
Loaded '/app/bin/x64/Debug/netcoreapp3.1/Microsoft.Bcl.HashCode.dll'. Cannot find or open the PDB file.
Loaded '/usr/share/dotnet/shared/Microsoft.NETCore.App/3.1.8/System.Collections.Immutable.dll'. Cannot find or open the PDB file.
Loaded '/app/bin/x64/Debug/netcoreapp3.1/Localization.dll'. Symbols loaded.
Microsoft.EntityFrameworkCore.Infrastructure: Information: Entity Framework Core 3.1.4 initialized 'BIMocularContext' using provider 'Npgsql.EntityFrameworkCore.PostgreSQL' with options: None
info: Microsoft.EntityFrameworkCore.Infrastructure[10403]
Entity Framework Core 3.1.4 initialized 'BIMocularContext' using provider 'Npgsql.EntityFrameworkCore.PostgreSQL' with options: None
Loaded '/usr/share/dotnet/shared/Microsoft.NETCore.App/3.1.8/Microsoft.Win32.Primitives.dll'. Cannot find or open the PDB file.
Loaded '/usr/share/dotnet/shared/Microsoft.NETCore.App/3.1.8/System.Security.Cryptography.X509Certificates.dll'. Cannot find or open the PDB file.
Loaded '/usr/share/dotnet/shared/Microsoft.NETCore.App/3.1.8/System.Collections.NonGeneric.dll'. Cannot find or open the PDB file.
Loaded '/usr/share/dotnet/shared/Microsoft.NETCore.App/3.1.8/System.Net.Sockets.dll'. Cannot find or open the PDB file.
Loaded '/usr/share/dotnet/shared/Microsoft.NETCore.App/3.1.8/System.Net.NameResolution.dll'. Cannot find or open the PDB file.
Exception thrown: 'System.Net.Internals.SocketExceptionFactory.ExtendedSocketException' in System.Net.NameResolution.dll
Exception thrown: 'System.Net.Internals.SocketExceptionFactory.ExtendedSocketException' in Npgsql.dll
Exception thrown: 'System.Net.Internals.SocketExceptionFactory.ExtendedSocketException' in System.Private.CoreLib.dll
Exception thrown: 'System.NullReferenceException' in Npgsql.dll: 'Object reference not set to an instance of an object.'
Stack trace:
> at Npgsql.NpgsqlConnector.Cleanup()
The program 'dotnet' has exited with code 0 (0x0).
当我将连接字符串更改为:
“ConnectionString”:“主机=posgres;端口=5400;数据库=test;用户名=postgres;密码=test;”
我在docker上也有同样的错误,但它在IIS上不起作用
当我将连接字符串更改为:
“ConnectionString”:“@Host=postgres;Port=5400;Database=test;Username=postgres;Password=test;”
我有一个例外:
不支持关键字:@host'