开发者

named connection not found (Entity framework problem)

I'm building multi-project Application where some UserControl, the user control has a Entitymodel object (myDBContainer db = new myDBContainer()), when i drop my user control on my a form i 开发者_如何学编程got the following designer error

The specified connectionis either not found in the configuration, not intended to be used with the entityclient provider


This means that the Entity Framework connection string isn't found in the Web.config or App.config for your project. Note that this connection string is not the same as the DB connection string.


Well, I found a solution for this but, I don't know is it the optimum or not. I put the connection string in the app.config through Settings file, and change the named connection in the constructor for the EF model designer to read this connection as the following

public InvDB() : base(Properties.Settings.Default.InvDB, "InvDB")

but this solution, you've to make this change every time you open the EF designer, but it's good for now.

0

上一篇:

下一篇:

精彩评论

暂无评论...
验证码 换一张
取 消

最新问答

问答排行榜