How to force ADO.NET Entity Framework to regenerate code?

Ken Henderson picture Ken Henderson · Jan 23, 2009 · Viewed 10.7k times · Source

I've run into a snag with a ADO.NET Entity Framework model and a ADO.NET Data Service that is making it available. The model and data service are compiling without any problems or warnings when they come out of source control. However when I run the service I get the following error: Request Error - The server encountered an error processing the request.  See server logs for more details.

Unfortunately there are no server logs (that I am aware of) since this is VS 2008 web dev server and there really isn't any code to debug..... Through some trial and error it would appear that the generated code (model.Designer.cs) is out of date in some manner. If I perform some trivial update to the EDM that forces it to regenerate the code file, when I rerun the service it works just fine.

I've tried to delete the model.designer.cs file in the hopes that during the build the project/entity builder would detect the missing file and regenerate it for me. That didn't happen..... Does anyone know how to force this code to be regenerated? (It would also make me a bit happier about not having to keep generated code under source control.)

Thanks

Answer

Andrew Peters picture Andrew Peters · Jan 26, 2009

Right click on the EDMX file and select Run Custom Tool.

There is also a command line code generation tool called edmgen (available from a VS Command Prompt).