views:

762

answers:

1

Hi, I really appreciate it if you could ask my question. After I call myObjectContext.myEntitySet.ToList() method in my entity framework context, the password part from connectionstring in myObjectContext.Connection.ConnectionString is gone.is it a bug? thanks very much for your help.

+2  A: 

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

So then 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 would be as follows:

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

As you can see this connection string doesn't contain a user name or password. Instead your windows user name and password is used. If you can you should use this instead of the former.

Rune Grimstad