views:

278

answers:

2

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

A: 

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.

Craig Stuntz
No it is there and it is as the EF write it, i didn't change it
Mustafa Magdy
You are telling me it's there, but the EF says it isn't. No offense, but I would tend to believe the EF. Are you sure you're looking at the *right* config file? If your model and main app are in different assemblies, the correct config file at runtime will be the main app's file, not the model's, and hence *not* the config file the EF wrote.
Craig Stuntz
A: 

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.

Mustafa Magdy
So you have the wrong connection name on your model. Like I said in my answer, the connection string isn't there. Fix the model or the .config file to agree.
Craig Stuntz
No, the connection already exists and named correctly and every time I open the Model it reset it again so the problem is not in the connection name, you got me?. I thing this maybe an "Beta" issue.
Mustafa Magdy