views:

390

answers:

5

Hello,

I'm trying to add a new ADO.Net Entity Data Model to an MVC project I am working on.

When I complete the wizard, choosing my db and tables (just a single table for now) I get an error ""Exception has been thrown by the target of an invocation." and it throws me back the add new item dialog.

At this point, an empty Data Model has been created in my project. If I then choose "Update Model From Database" and complete the wizard again, I get a similar error.

An exception of type 'System.Reflection.TargetInvocationException' occurred while attempting to update from the database. The exception message is: 'Exception has been thrown by the target of an invocation.'.

Any ideas? I have tried doing this in an empty project also and still no dice!

Alex

A: 

I am getting exactly the same problem whilst trying to following this tutorial, which is my first step in learning MVC, so I'm not getting very far. I am using Visual Studio 2008 Development Edition with .Net 3.5 SP 1 and MVC 1, and I have used the Web Platform Installer to make sure everything is use to date, but still no joy.

ShellShock
A: 

Try turning on the include exception faults behaviour

namespace DataService { [System.ServiceModel.ServiceBehavior(IncludeExceptionDetailInFaults = true)]

public class mydataservice : DataService<DataContext>
{
    blah blah
developeruk
I voted this answer down for I can't see what this got to do with the Entity Framework. The example seems to come from Astoria/ ADO.NET Data Services.
norbertB
+1  A: 

You could try creating the Entity Data Model manually using the EdmGen.exe tool. Hopefully that will give a bit more information about the error.

cofiem
A: 

I had similar issue. Look for similar names and missing mapping of forgen keys

tsinik
A: 

I have had the same exeption, in my case it was my db(MySql) that had a table without a primary key, I just added a column "ID" and made it the primary key and voila! the exeption was gone :)

Bobby