I have an ASP.NET MVC 5 application. And I use Entity Framework 6 Code First in order to access a database in another machine.
I use the connection string from the DbContext to make another direct sql query to the database, using a micro ORM. In order to get the connection string I use:
myContext.Database.Connection.ConnectionString
The problem is that inside an Action, the connection string changes after a call to the method "Find" on a context DbSet. Previously, the database password is there, but after calling this method, the password just goes away.
Has anybody experienced such change to the connection string?
Thank's in advance.
This is per design. See https://connect.microsoft.com/VisualStudio/feedback/details/514829/datacontext-getcommand-alters-the-contexts-connection-string
You have to save the connection string before it has opened.