我正在使用EntityConnectionStringBuilder创建ConnectionString到MySQL数据库,但是我收到错误"不支持关键字:"提供程序"我不知道为什么会收到此错误
我的代码
EntityConnectionStringBuilder csb = new EntityConnectionStringBuilder();
csb.ProviderConnectionString = "Server=Ip;User Id=user;Password=123456;database=dev pooling=false";
csb.Provider = "MySql.Data.MySqlClient";
return csb.ConnectionString;
请帮助我解决此错误,我使用实体框架
连接字符串中缺少分号 ";"。我不知道修复是否可以像这样解决问题。错误消息中指责提供程序,因为它是EntityConnectionStringBuilder
中连接字符串之后的下一个属性:
EntityConnectionStringBuilder csb = new EntityConnectionStringBuilder();
csb.ProviderConnectionString = "Server=Ip;User Id=user;Password=123456;database=dev;pooling=false";
csb.Provider = "MySql.Data.MySqlClient";
return csb.ConnectionString;
我建议使用单独的SQLConnectionStringBuilder
,并像这样设置 Pooling
属性:
string connectionString = "Server=Ip;User Id=user;Password=123456;database=dev";
System.Data.SqlClient.SqlConnectionStringBuilder scsb = new System.Data.SqlClient.SqlConnectionStringBuilder(connectionString);
scsb.Pooling = true;
EntityConnectionStringBuilder csb = new EntityConnectionStringBuilder();
csb.ProviderConnectionString = scsb.ConnectionString;
csb.Provider = "MySql.Data.MySqlClient";
return csb.ConnectionString;