由于是winform 所以不想把连接字符串在 config文件中进行配置,想在代码里面写死,连接的是mysql数据库,不知该如何设置
private static string ConnectStr()
{
string connectStr = "Server="
+ "127.0.0.1" + ";port=3306;DataBase="
+ "dbtest1" + ";persist security info=True;user id="
+ "root" + ";password="
+ "123456" + ";Allow Zero Datetime=true;Allow User Variables=True;Charset=utf8;";
return connectStr;
}
public DBContext()
//: base("name=connectionString")
: base(ConnectStr())
{
}
这里居然报 "不支持关键字: “port”。"
做过的请回答
+ "127.0.0.1" + ";port=3306;DataBase="
改成
+ "127.0.0.1:3306" + ";DataBase="
No Entity Framework provider found for the ADO.NET provider with invariant name 'System.Data.SqlClient'. Make sure the provider is registered in the 'entityFramework' section of the application config file. See http://go.microsoft.com/fwlink/?LinkId=260882 for more information.
觉得是应该要指定 providerName=MySql.Data.MySqlClient;
否则默认是 EntityFramework.SqlServer
@晓道: System.ArgumentException:“不支持关键字: “providername”。”