I trying to create a application with use some Entity Framework and some old DataSets but I only have a dynamic connection string using entity and need remove metadata at runtime to create a connection string to my database. Anyone know a way to remove all metadata from Entity Framework Connection
I have this
metadata=res://*/Models.SiteModel.csdl|res://*/Models.SiteModel.ssdl|res://*/Models.SiteModel.msl;provider=System.Data.SqlClient;provider connection string="Data Source=(local);Initial Catalog=MyDB;Persist Security Info=True;User ID=sa;Password=P@ssw0rd;MultipleActiveResultSets=True"
and need only this:
Data Source=(local);Initial Catalog=MyDB;Persist Security Info=True;User ID=sa;Password=P@ssw0rd;MultipleActiveResultSets=True
You can use the EntityConnectionStringBuilder
class:
string connectionString = "metadata=res://*/Models.SiteModel.csdl|res://*/Models.SiteModel.ssdl|res://*/Models.SiteModel.msl;provider=System.Data.SqlClient;provider connection string=\"Data Source=(local);Initial Catalog=MyDB;Persist Security Info=True;User ID=sa;Password=P@ssw0rd;MultipleActiveResultSets=True\"";
EntityConnectionStringBuilder builder = new EntityConnectionStringBuilder(connectionString);
builder.Metadata = null;
connectionString = builder.ConnectionString;
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With