Reputation:
I've done the following steps:
- Open visual studio
- Create new item
- Select "ADO.Net Entity Data Model"
- Point it to an existing database
- Accept all the defaults.
- It then adds a "Model1.edmx" file to my solution and the corresponding "Model1.Designer.cs" file.
However in the output I get the following error:
"ERROR: Unable to generate model because of the following exception: 'Value does not fall within the expected range.'."
I've created a model from this database before so I dont think the error is a result of complex table design (which it's not).
Has anyone else hit this error?
Thanks
Upvotes: 6
Views: 8729
Reputation: 395
I had same problem, the easy solution is : delete your model from visual studio and and new ado.net model with same name, before that delete all connection string from config file
Upvotes: 0
Reputation: 11
I experienced the same issue with a MYSQL database using Ria services.
Solution:
I found the entity model requires a primary key in at least one table when multiple tables are imported.
The primary key for my table was also set to auto increment.
Upvotes: 1
Reputation: 21664
I've just been investigating a similar issue. It turns out that Entity Framework outputs additional error information in the Messages
section of the Error List
window in Visual Studio.
As you can see it's much more useful than the generic error that appears in the Output
window. This was crucial in helping me to solve my problem.
Upvotes: 0
Reputation: 3158
You can add one table to the model first and when the edmx file is created, you can update model from the database. It worked for me. I wish it solve ur prblem too.
cheers Parminder
Upvotes: 0
Reputation: 990
When I'm unable to open the 'Design View' while clicking on the model.edmx file I Unload the project in VS2008 and then load it back up again and it seems to fix that problem.
Upvotes: 1
Reputation: 1256
Please check whether the primary key has been defined for the table. If you open the entity model in xml editor, you should be able to see commented error message, the comment might help you!
Upvotes: 1
Reputation:
I had a similar problem. The reason was pretty simple. I've forgotten to set a primary key in one of my tables. Hope it helps.
Upvotes: 2
Reputation:
Ok.
I was able to readd it.
Here's what I did.
All the steps above in the bullet points plus:
Still stumped on how to resolve this.
Upvotes: 1
Reputation:
Ok....
I think I might have a solution.
I've just done the following and it worked.
It now works.
Un-nerving.
But it works.
Upvotes: 1