none
Why would password of ConnectionString be filtered after instantiating any object in Entity Framework? RRS feed

  • Question

  • I found that when I run instantiation by a DbContext, the Database.Connection.ConnectionString will be changed that the password property would be cleared.

    Why?

    before

    after

    • Edited by Indream Luo Sunday, February 23, 2014 8:08 AM Fix images
    Wednesday, February 12, 2014 9:55 AM

Answers

  • This is not EF-specific and is by design. After opening a DbConnection the password is removed from the connection string for security reasons so that you can pass around the connection object without exposing the password. If you really need to keep the password (highly discouraged) specify the 'Persist Security Info=true' parameter in the connection string, then it won't be removed on connect.
    Thursday, February 13, 2014 10:05 AM

All replies

  • Hello Luo,

    Images are broken, could you please upload them again?

    Regards.


    We are trying to better understand customer views on social support experience, so your participation in this interview project would be greatly appreciated if you have time. Thanks for helping make community forums a great place.
    Click HERE to participate the survey.

    Thursday, February 13, 2014 4:24 AM
    Moderator
  • This is not EF-specific and is by design. After opening a DbConnection the password is removed from the connection string for security reasons so that you can pass around the connection object without exposing the password. If you really need to keep the password (highly discouraged) specify the 'Persist Security Info=true' parameter in the connection string, then it won't be removed on connect.
    Thursday, February 13, 2014 10:05 AM
  • Thanks a lot.

    I found that it's a setting for ADO.NET connections, but wondering if it's a ADO.NET design or some protocol.

    Is it a design of ADO.NET or lower layer other something?

    Sunday, February 23, 2014 8:14 AM
  • Fixed, thanks for notice.
    Sunday, February 23, 2014 9:54 AM