System.Resources.MissingManifestResourceException when Updating database

时光毁灭记忆、已成空白 提交于 2019-12-05 03:51:37

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 :-)

Sarfraz Keshwani

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.

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.

Unloading and then reloading migration file worked for me!

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.

If anybody wants to look into the source or compiler to know why this is happening; I don't feel like it right now. After an hour of tinkering, my resolution is odd.

Granted, I shouldn't have done this in the first place, but for quick code I temporarily added classes into the same file as my generated DbMigration 201906212110305_initial.cs. The mere existence of those temporary classes in the same file caused this error. As soon as I moved them to their own file (which I was going to do all along anyway) the runtime error vanished.

易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!