如何在WPF中连接实体框架 [英] how to connect Entity Framework in wpf
本文介绍了如何在WPF中连接实体框架的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!
问题描述
嗨
我有一个类库项目和一个WPF项目.
我正在尝试在类库中编写代码以使用实体框架连接到wpf项目.我收到错误消息配置系统初始化失败"
以下是App.Config
中的代码
Hi
I have a class library project and a WPF Project.
I am trying to write code inside class library to connect to a wpf project using entity framework. I get error "Configuration system failed to initialize"
below is the code in App.Config
<connectionStrings>
<add name="dbQuickPhonebookContainer"
connectionString="metadata=.\dBase.dbQuickPhonebook.csdl|.\dBase.dbQuickPhonebook.csdl|.\dBase.dbQuickPhonebook.msl;provider=System.Data.SqlClient; provider connection string="Data Source=localhost;attachdbfilename=|DataDirectory|\dbQuickPhonebook.edmx;Initial Catalog=dbQuickPhonebook;Integrated Security=True;MultipleActiveResultSets=False""
providerName="System.Data.EntityClient" />
</connectionStrings>
以下是我班上的代码
below is the code inside my class
public class BusinessLayer
{
string connString;
public BusinessLayer()
{
connString = ConfigurationManager.ConnectionStrings ["dbQuickPhonebookContainer"].ConnectionString;
}
}
请帮助我在类内编写代码以获得连接字符串的名称.
Please help me write code inside the class to get the name of connection string.
推荐答案
您好检查了Wes给您的链接,它是否对您有帮助:
http://social.msdn.microsoft.com /Forums/zh-CN/vbgeneral/thread/41cfc8e2-c7f4-462d-9a43-e751500deb0a/ [ http://msdn.microsoft.com/en-us/netframework/first- steps-with-wcf.aspx [ ^ ]
祝您好运:)
Hi did you check out the link Wes gave you, and did it help:
http://social.msdn.microsoft.com/Forums/en-US/vbgeneral/thread/41cfc8e2-c7f4-462d-9a43-e751500deb0a/[^]
If not Im going to give you the link to the Microsoft documentation that contains a hole lot of articles and videos on the subject:
http://msdn.microsoft.com/en-us/netframework/first-steps-with-wcf.aspx[^]
So good luck to you :)
这篇关于如何在WPF中连接实体框架的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!
查看全文