I had a web project that compiled and ran fine. I made a back up of it then tried modifying the Entity framework so that the code was generated using EF5 DbContext. That led to to the "Unable to load the specified metadata resource".
So I started copying over code from the back up copy until I have to all intents and purposes the same solution as the back up one. The back up one still runs fine but on this I still get the same error.
I copied over the entire Web.config and App.config code
I copied over the code generated .cs code (though did then do a Build solution afterwards -- but don't think that should do anything?)
I even pointed the corrupt solution to the same db as the working one.
Right I finally(!) worked it out. I compared the .csproj files for both my "models", found the following differences, then copied the replaced the incorrect csproj file with the correct one and everything is working again.
No idea what the following refer to but I've documented the differences that were causing the problem anyhow. To help other newbies, this is what you might wish to change in your csproj file for your "model" (the one with the database model) after you "Reflect"
(i.e decompile) your Assembly files and find that the resources folder is missing.
[Side note: To reflect your assembly file, download a trial of .net reflector, then use if on the dll file stored in your websites bin folder. The dll will have the same name as your model (or something similar).]
Anyway here are the differences I observed. I suspect the last item is the biggest culprit. It wasted an entire day of vacation for me!
2) Incorrect version (occured twice): <WarningLevel>4</WarningLevel> <Prefer32Bit>false</Prefer32Bit> </PropertyGroup>
Correct version (occured twice): <WarningLevel>4</WarningLevel> </PropertyGroup>
3) In incorrect version but not in correct version: <ItemGroup> <Reference Include="EntityFramework"> <HintPath>..\packages\EntityFramework.5.0.0\lib\net40\EntityFramework.dll</HintPath> </Reference>
4) In incorrect version but not in correct version: <Reference Include="System.ComponentModel.DataAnnotations" /> <Reference Include="System.Xml.Linq" />
PuzzledGeek
Member
1 Points
33 Posts
Unable to load the specified metadata resource -- driving me crazy!
Dec 18, 2012 11:02 PM|LINK
Ok so this is driving me crazy.
I had a web project that compiled and ran fine. I made a back up of it then tried modifying the Entity framework so that the code was generated using EF5 DbContext. That led to to the "Unable to load the specified metadata resource".
So I started copying over code from the back up copy until I have to all intents and purposes the same solution as the back up one. The back up one still runs fine but on this I still get the same error.
I copied over the entire Web.config and App.config code
I copied over the code generated .cs code (though did then do a Build solution afterwards -- but don't think that should do anything?)
I even pointed the corrupt solution to the same db as the working one.
But I still get that error... why??
PuzzledGeek
Member
1 Points
33 Posts
Re: Unable to load the specified metadata resource -- driving me crazy!
Dec 19, 2012 12:32 AM|LINK
Right I finally(!) worked it out. I compared the .csproj files for both my "models", found the following differences, then copied the replaced the incorrect csproj file with the correct one and everything is working again.
No idea what the following refer to but I've documented the differences that were causing the problem anyhow. To help other newbies, this is what you might wish to change in your csproj file for your "model" (the one with the database model) after you "Reflect" (i.e decompile) your Assembly files and find that the resources folder is missing.
[Side note: To reflect your assembly file, download a trial of .net reflector, then use if on the dll file stored in your websites bin folder. The dll will have the same name as your model (or something similar).]
Anyway here are the differences I observed. I suspect the last item is the biggest culprit. It wasted an entire day of vacation for me!
1) Incorrect version: <TargetFrameworkVersion>v4.0</TargetFrameworkVersion> <FileAlignment>512</FileAlignment> <TargetFrameworkProfile />
Correct version: <TargetFrameworkVersion>v4.0</TargetFrameworkVersion> <FileAlignment>512</FileAlignment>
2) Incorrect version (occured twice): <WarningLevel>4</WarningLevel> <Prefer32Bit>false</Prefer32Bit> </PropertyGroup>
Correct version (occured twice): <WarningLevel>4</WarningLevel> </PropertyGroup>
3) In incorrect version but not in correct version: <ItemGroup> <Reference Include="EntityFramework"> <HintPath>..\packages\EntityFramework.5.0.0\lib\net40\EntityFramework.dll</HintPath> </Reference>
4) In incorrect version but not in correct version: <Reference Include="System.ComponentModel.DataAnnotations" /> <Reference Include="System.Xml.Linq" />
5) Incorrect version: <ItemGroup> <None Include="ModelCBS.edmx"> <Generator>EntityModelCodeGenerator</Generator> <LastGenOutput>ModelCBS.Designer.cs</LastGenOutput> </None> </ItemGroup> <ItemGroup> <None Include="App.Config"> <SubType>Designer</SubType> </None> <None Include="packages.config" /> </ItemGroup> <ItemGroup> <Service Include="{508349B6-6B84-4DF5-91F0-309BEEBAD82D}" /> </ItemGroup>
6) Correct version: <ItemGroup> <EntityDeploy Include="ModelCBS.edmx"> <Generator>EntityModelCodeGenerator</Generator> <LastGenOutput>ModelCBS.Designer.cs</LastGenOutput> </EntityDeploy> </ItemGroup> <ItemGroup> <None Include="App.Config" /> </ItemGroup> <ItemGroup> <Content Include="ModelCBS.edmx.sql" /> </ItemGroup>