I was reading the Book called Professional MVC 2 , following the tutorial to Page 44.
When I run the application, /Details/id, which will invoke the Entity framework to do a DB query. No luck, get an strange error.
Line 37: /// Initializes a new nerdDinnerEntities object using the connection string found in the 'nerdDinnerEntities' section of the application configuration file.
[MetadataException: Unable to load the specified metadata resource.]
[TargetInvocationException: Exception has been thrown by the target of an invocation.]
[InvalidOperationException: An error occurred when trying to create a controller of type 'LADinner.Controllers.DinnersController'. Make sure that the controller has a parameterless public constructor.]
Then I check the web.config. the connection string is there.
So the runtime will read some resource file embedded in the Assembly. So are the name correct?
I just run a ILDASM NerdDinner.DLL /out:a.il
c:\NerdDinner\bin>ildasm NerdDinner.dll /out:a.il
Directory of c:\NerdDinner\bin
10/25/2010 05:23 PM <DIR> .
Here, for those resource file, Pay attantion to the filename. this is no Assmebly name as the prefix.
Models.NerdDinners.csdl Instead of NerdDinner.Models.NerdDinners.CSDL which is defined in the web.config
so remove the nerddinner in web.config , that’s the trick to fix the problem