How do I create connection string programmatically to MS SQL in Entity Framework 6?
I\'m using c# and WPF and I was wondering if someone could show me how or link me to
I previously used the DefaultConnection string found in the app.config ( or web.config) as example and just replaced the "connectionstring" on the DbContext, to the one i wanted.
The connectionstring looked something like :
Data Source=(LocalDb)\MSSQLLocalDB;AttachDbFilename=|DataDirectory|\aspnet-ShoppingList.Web-20150903103641.mdf;Initial Catalog=aspnet-ShoppingList.Web-20150903103641;Integrated Security=True
If i'm remembering correctly, you should replace the connectionstring in :
DbContext.Database.Connection.Connectionstring
PS. You can only use it this way if you are using Code-First. If you are using Model-First or Database-First you should use the EntityConnectionStringBuilder .