Entity Framework and TFS Build

I recently had an issue when trying to configure automatic deployments in TFS.
I was building a MS Deploy package with one build definition and deploying it with another.
The application was based on ASP.NET MVC with Entity Framework as a ORM
When I tried to open the application on the target server, I got an error "Unable to load the specified metadata resource".

The entity data model was configured to store the model files as resources into the assembly. The error was caused by the fact that the build process was no longer executing the packaging step. Usually Visual Studio does it automatically for you but MSBuild is not so kind. You have to manually tell it to execute the EntityDeploy step.

I added an instruction in the project file (containing the data model) to execute the packaging step.

<Target Name="AfterBuild">
  <EntityDeploy Sources="Models\DataModel.edmx" outputPath=".">

After that I made sure the build definition specified the MSBuild switch to rebuild the binaries (and not just build).

Popular posts from this blog

Adding a delay before processing Textbox events

Handling exceptions the right way in WCF (part 2)

Create a draft release and start it using the TFS REST API