System.Resources.MissingManifestResourceException

2019-04-21 09:03发布

问题:

I moved a web application I am working on from one machine to another. It is built using .Net MVC and Entity Framework but when I execute the Update-Database command so that the database is updated, I get this error:

Could not find any resources appropriate for the specified culture or the neutral culture.  Make sure "NameofMigration.resources" was correctly embedded or linked into assembly "NameofProject" at compile time, or that all the satellite assemblies required are loadable and fully signed.

Does anyone know how to fix this error?

回答1:

I had a similar issue when the resx part of the migration was not included in the project file when a fellow developer checked the project in (probably due to a merge issue). You may find that the resx file is there but greyed out. If it's there, try right clicking the "NameofMigration.resx" file and selecting "include in project". If it's not there, you better go find it on the other machine and add it to the project :-)



回答2:

I encountered the same issue (VS 2017) and none of the solutions provided here worked. I fixed the problem by cleaning the solution and manually deleting the bin folder and then building it again.



回答3:

Unloading and then reloading migration file worked for me!



回答4:

For VS 2017, the solution is as follows:

Go to the project file, and for all of the migrations, apply the following format:

 <Compile Include="Migrations\201804251606403_emailsWithEffort.cs" />
<Compile Include="Migrations\201804251606403_emailsWithEffort.Designer.cs">
  <DependentUpon>201804251606403_emailsWithEffort.cs</DependentUpon>
</Compile>

    <EmbeddedResource Include="Migrations\201804251606403_emailsWithEffort.resx">
  <DependentUpon>201804251606403_emailsWithEffort.cs</DependentUpon>
</EmbeddedResource>

I guess that the problem is when changing version(s) of Visual Studio, old format of describing dependencies stays, and the Visual Studio 2017 can not interpret it correctly.

Hence, applying the format as described above (change your format to this), you can make the Visual Studio get the idea of where it's resources are.



回答5:

Slightly different situation, where I created a new environment, and database, and received the above error message.

For my fix, I had to right-click on the migration files (initial and resx) and set property to embedded as resource. Update-database command ran fine afterward.