.NET Core 2 - 具有实例名称和端口号的连接字符串

问题描述 投票:0回答:1

在我的应用程序中,我在配置中有一个连接字符串。此应用程序使用.NET核心2.11和SQL Server创建。这是连接字符串:

Data Source=servername\instancename, portnumber;Initial Catalog=dbname;Persist Security Info=True;User ID=username;Password=password;

此字符串会导致错误,如下所示:

enter image description here

如果我在字符串中使用实例名称和端口号,则会发生此错误。如果我删除任何一个,它正在工作。那么,如何在连接字符串中使用实例名称和端口号?

sql-server asp.net-core database-connection
1个回答
0
投票

找到了答案。实例名称将使用动态端口,因此我无法使用默认端口号(1433)。需要将端口号更改为使用1433而不是动态端口。

© www.soinside.com 2019 - 2024. All rights reserved.