避免在WPF项目app.config中公开连接字符串 [英] Avoid Expose connection string in WPF project app.config

查看:104
本文介绍了避免在WPF项目app.config中公开连接字符串的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述


我有WPF项目,类库正在使用数据库第一种方法处理EF 6.0。现在我想要实体类进入我的启动项目(WPF项目)而不在启动项目app.config中添加连接字符串。我谷歌出类EntityConnectionStringbuilder
,这将有助于生成动态连接字符串。但是,我找不到使用数据库第一种方法和entityconnectionstringbuilder的解决方案。



让我们说,如果我写使用(var dbentities = new DB_Entities())所以在哪里传递连接字符串和DB_Entities构造函数是自动生成的,因为我有DB第一种方法


< p style ="padding-right:0px; line-height:inherit; vertical-align:baseline; clear:both">
请帮我在Db第一种方法中传递连接字符串或者先与db相关的任何其他东西。

解决方案

你好takehicastle1233,


根据你的描述,你有一些关于EntityConnectionStringbuilder的问题,我找到一个关于这个的线程,你c参考:


https://social.msdn.microsoft.com/Forums/en-US/32629f81-1497-4b87-8cbb-a311c102e3fb/wpf-entity-framework-conection-string ?forum = adodotnetentityframework



最好的问候,


Cherry


I have WPF project and class library is handling EF 6.0 with Database first approach. Now i want entity classes into my startup project(WPF project) without adding connection string in startup project app.config. I google out class EntityConnectionStringbuilder that will help to generate dynamically connection string. But, I can't find solution with database first approach and entityconnectionstringbuilder.

Let say, if i write using(var dbentities = new DB_Entities()) so where to pass connection string and DB_Entities constructor is auto generated as I have DB first approach

Please help me to pass connection string in Db first approach or any other thing related to db first.

解决方案

Hi takeshicastle1233,

According to your description, you have some issue about EntityConnectionStringbuilder, I find one thread about this, you can refer to:

https://social.msdn.microsoft.com/Forums/en-US/32629f81-1497-4b87-8cbb-a311c102e3fb/wpf-entity-framework-conection-string?forum=adodotnetentityframework

Best Regards,

Cherry


这篇关于避免在WPF项目app.config中公开连接字符串的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆