Problem getting connectionstring from objectcontext.Connection.ConnectionString

I really appreciate it if you can ask your question. After I call the myObjectContext.myEntitySet.ToList () method in the context of the entity context, the password portion from the connection string is missing in myObjectContext.Connection.ConnectionString. This is mistake? Many thanks for your help.

0


source to share


1 answer


This is by design. The password will be removed to protect you. If you really want to store the password there, you can add the following to your connection string:Persist Security Info=True;

So, your connection string should look something like this:

Data Source=server;Initial Catalog=database;User ID=user;Password=password;Persist Security Info=True;

      



Be aware that this is a security risk. If your database server supports Windows authentication, you should use that instead. Then your connection string will look like this:

Data Source=server;Initial Catalog=database;Integrated Security=True

      

As you can see, this connection string does not contain a username or password. Instead, your window's username and password are used. If you can use this instead of the first one.

+2


source







All Articles