我正在构建我的第一个 ASP.NET Core Web 应用程序,并为其使用 MySQL 数据库。 使用 EF Core Power Tools 导入 DB-Context 后,我将连接字符串保存在 appsettings.json 文件中。
然后我尝试加载其中一个实体类的索引 View ,但我不断收到以下错误:
ArgumentException: Keyword not supported: 'allowuservariables'.
我尝试将“allowuservariables=true”从连接字符串中抛出,但随后收到此错误消息:
SqlException: A network-related or instance-specific error occurred while establishing a connection to SQL Server. The server was not found or was not accessible. Verify that the instance name is correct and that SQL Server is configured to allow remote connections. (provider: Named Pipes Provider, error: 40 - Could not open a connection to SQL Server)
连接字符串:“server=localhost;user id=root;database=dbname;allowuservariables=True;password=password;persistsecurityinfo=True”
连接字符串有问题还是我缺少识别“allowuservariables”的扩展名?
最佳答案
该代码尝试使用 SqlConnection
连接到 MySQL 数据库,但这不起作用。
确保您在 Startup 的
文件,如 documented here .ConfigureServices
中调用了 UseMySql
,而不是 UseSqlServer
.cs
关于c# - ASP.NET Core 项目中的 MySql 连接字符串错误,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/65751885/