How to encrypt and decrypt entity framework connection string RRS feed

  • Question

  • My original EF connection string is metadata=res://*/XYZ.csdl|res://*/XYZ.ssdl|res://*/XYZ.msl;provider=System.Data.SqlClient;provider connection string="Data Source=abcd;Initial Catalog=1234;User ID=userBPM;Password=yrtrrjeu;  MultipleActiveResultSets=True;Application Name=EntityFramework"" providerName="System.Data.EntityClient"

    I have encrypt and decrypt  methods for   EF connection string using Cryptography.ProtectedData.Protect and Unprotect class.  EF will not automatically decrypt the connection string.Hence I would like know  where exactly I need to decrypt the connection string. 

    Wednesday, July 8, 2015 1:51 PM


  • Hi Pavan,

    --> I would like know  where exactly I need to decrypt the connection string. 

    As far as I know, you could decrypt the connetion string  in application initialization code before DbContext is even initialized.

    string conn = "YourDecrypted connectionstring";
    public yourcontext(conn):base(conn) 

    Youjun Tang

    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.

    • Marked as answer by Fred Bao Tuesday, July 21, 2015 1:18 AM
    Friday, July 10, 2015 1:35 AM