I am using Entity Framework and in my solution there are 9 projects and it will enlarge. My problem is stating connection string in .config file. When I did like this, I had to state connection string for 4-5 projects and when I wanted to change my connection, changing ConnectionStrings is becoming an obligation for 4 or 5 projects. I want to set connection string in DbContext constructor. DbContext can provide me this ability but I can't define providerName.So dbconnection of context automatically use SqlClient but I want to use MySql provider. My connection string is :
"Server=localhost;Database=xxx;Uid=auth_windows;Persist Security Info=True;User=root;Password=yyyyyy;"
Also I can't specify provider name in connection string like "Provider = MySql.Data.MySqlClient". It throws exception "Provider keyword is not supported".
I am changing my question for more comprehensible.
In short I want to to this.
public class XxContext : DbContext
{
public XxContext()
{
this.Database.Connection.Provider = "MySql.Data.MySqlClient";
this.Database.Connection.ConnectionString = "Server=localhost bla bla bla";
}
}
But I don't know how to state you should use MySql.Data.MySqlClient(without config file). Is it possible ? If it is, how can I do ?