I have many databases in my server which have the same two tables. The databases are named Hello1, Hello2 etc. They are created in runtime. I’m adding an .edmx item in my project for Hello1. I want to use the same .edmx file for the other databases because they all have the same tables (with different rows of course).
The connection string in my web.config file is this one:
<connectionStrings>
<add name="MyEntities" connectionString="metadata=res://*/MyEntities.csdl|res://*/MyEntities.ssdl|res://*/MyEntities.msl;provider=System.Data.SqlClient;provider connection string="Data Source=10.10.10.10;Initial Catalog=Hello1;User ID=myUser;Password=myPassword;MultipleActiveResultSets=True"" providerName="System.Data.EntityClient" />
</connectionStrings>
In my C# code I want this:
MyEntities me = new MyEntities(theConnectionString);
theConnectionString will be the same as above, but instead Hello1 it will have the right database name. What should be the value of theConnectionString?
I tried this, but it isn’t working:
"metadata=res://*/MyEntities.csdl|res://*/MyEntities.ssdl|res://*/MyEntities.msl;provider=System.Data.SqlClient;provider connection string="Data Source=10.10.10.10;Initial Catalog=Hello6;User ID=myUser;Password=myPassword;MultipleActiveResultSets=True""
Try replacing
"with single quotes: