-2

Current project:

  • DotNet 4.7.1
  • MVC 5
  • Database-first from a legacy DB, [DbName].edmx file in /Models/

When trying to build the project in order to test it, I am getting a sudden error (CS1566) that there was an error reading the resource Models.[DbName].csdl, and it could not find part of the path. Sure enough, the entire \edmxResourcesToEmbed\Models\ folder was missing from the \obj\Debug\ directory.

How do I rebuild this? This is my first database-first project, everything else has been code-first, and Google is bringing me back nothing.

René Kåbis
  • 842
  • 2
  • 9
  • 28

1 Answers1

-1

Thanks to StackOverflow’s ability to link in other posts you would normally not think were related, I was able to solve this problem.

This issue also came about because of code-first workflows that I had adopted that I needed in order to prevent errors under code first using multi-project repository patterns. Specifically, I modified my *.csproj files to always delete the bin and obj directories of the project(s) that I build/publish:

<Target Name="BeforeBuild">
  <!-- Remove obj folder -->
  <RemoveDir Directories="$(BaseIntermediateOutputPath)" />
  <!-- Remove bin folder -->
  <RemoveDir Directories="$(BaseOutputPath)" />
</Target>

Why? Because when I didn’t, any attempt to build/publish a code-first project would fail due to “multiple, conflicting web.config files”. Which I don’t have in the first place, but that’s what it complains about. So by habit, I just engineer each project to delete those two directories before building/publishing, so as to avoid that show-stopping error.

Essentially: the system was giving itself a fatal haircut every time it went to build or publish, by clearing out a bin file that was needed by the publish process. All thanks to me and code-first multi-project repository pattern solutions applied to a database-first project. Sweet. facepalm bridgepinch smh

And when I first made this post, I got one Related link shortly after posting. The first half of that reply made sense - select the *.edmx file and change the Build Action value, but the second half confused me until I actually opened up the *.edmx file and clicked on an empty part of the model diagram that came up -- suddenly, my properties sidebar changed to something completely different, which did have the Metadata Artifact Processing value that needed changing.

By following those instructions, then shutting down VS, then removing my *.csproj modifications, then opening the project back up, then building, then reversing those instructions and actually publishing, I was able to reverse the damage I had inadvertently done.

So, FYI for anyone else who has the same problem.

René Kåbis
  • 842
  • 2
  • 9
  • 28