Encrypt ConnectionString in entity framework (first code)

后端 未结 3 1744
有刺的猬
有刺的猬 2020-12-16 22:20

How can i protect my connection string? I want to use Entity framework 4.1 (first code) in C#, but it is important to me that other people can not see my Connection String.<

3条回答
  •  轻奢々
    轻奢々 (楼主)
    2020-12-16 22:58

    You can use the same tool that you can use for asp.net applications.

    Make sure to have a backup before you do the following!

    1. Look here: 'C:\Windows\Microsoft.NET\Framework' for your version or just the newest.
    2. Open the folder of your version
    3. Search for 'aspnet_regiis'
    4. Right-click it and select properties then copy the path of the location
    5. Now rename the 'app.config' file in your project to 'web.config' (you can do that in visual studio)
    6. Open the command prompt
    7. Type in '\aspnet_regiis -pef "connectionStrings" '
    8. Press enter
    9. It should give you something like 'Successfully encrypted' or so
    10. Now you can rename your 'web.config' file back to 'app.config'

    Now you can look into the app.config and see that the connection string is encrypted.

提交回复
热议问题