I'm moving our projects to the new SDK style, as the first step to a .NET Core migration. After migrating all projects, the one left was the class library which contained the EF code (DbContext, Migrations and so on). All the projects are running on .NET Framework 4.7.2. No .NET Core involved.
With the work done for 6.3 (thanks a lot!) I then went back to it to finally move the project to the new sdk style. These are the steps I made:
PackageReferences and deleted packages.configcsproj file to the new SDK style. Removed all EmbeddedResource from there. I still have the app.config in the class libraryUpdate-Database and it failed. The error is:Applying explicit migration: 201909170903584_Init.
System.Resources.MissingManifestResourceException: Could not find any resources appropriate for the specified culture or the neutral culture. Make sure "EFDemo.Data.Migrations.Init.resources" was correctly embedded or linked into assembly "EFDemo.Data" at compile time, or that all the satellite assemblies required are loadable and fully signed.
at System.Resources.ManifestBasedResourceGroveler.HandleResourceStreamMissing(String fileName)
at System.Resources.ManifestBasedResourceGroveler.GrovelForResourceSet(CultureInfo culture, Dictionary`2 localResourceSets, Boolean tryParents, Boolean createIfNotExists, StackCrawlMark& stackMark)
at System.Resources.ResourceManager.InternalGetResourceSet(CultureInfo requestedCulture, Boolean createIfNotExists, Boolean tryParents, StackCrawlMark& stackMark)
at System.Resources.ResourceManager.InternalGetResourceSet(CultureInfo culture, Boolean createIfNotExists, Boolean tryParents)
at System.Resources.ResourceManager.GetString(String name, CultureInfo culture)
at EFDemo.Data.Migrations.Init.System.Data.Entity.Migrations.Infrastructure.IMigrationMetadata.get_Target()
at System.Data.Entity.Migrations.DbMigration.GetModel(Func`2 modelAccessor)
at System.Data.Entity.Migrations.DbMigrator.ApplyMigration(DbMigration migration, DbMigration lastMigration)
at System.Data.Entity.Migrations.Infrastructure.MigratorLoggingDecorator.ApplyMigration(DbMigration migration, DbMigration lastMigration)
at System.Data.Entity.Migrations.DbMigrator.Upgrade(IEnumerable`1 pendingMigrations, String targetMigrationId, String lastMigrationId)
at System.Data.Entity.Migrations.Infrastructure.MigratorLoggingDecorator.Upgrade(IEnumerable`1 pendingMigrations, String targetMigrationId, String lastMigrationId)
at System.Data.Entity.Migrations.DbMigrator.UpdateInternal(String targetMigration)
at System.Data.Entity.Migrations.DbMigrator.EnsureDatabaseExists(Action mustSucceedToKeepDatabase)
at System.Data.Entity.Migrations.DbMigrator.Update(String targetMigration)
at System.Data.Entity.Infrastructure.Design.Executor.Update.<>c__DisplayClass0_0.<.ctor>b__0()
at System.Data.Entity.Infrastructure.Design.Executor.OperationBase.Execute(Action action)
Could not find any resources appropriate for the specified culture or the neutral culture. Make sure "EFDemo.Data.Migrations.Init.resources" was correctly embedded or linked into assembly "EFDemo.Data" at compile time, or that all the satellite assemblies required are loadable and fully signed.
If I leave the EmbeddedResource files as they were in the old .csproj: EmbeddedResource Include...., then the build fails as these files are already included with the new SDK style.
It goes on to suggest me to add <EnableDefaultCompileItems>false</EnableDefaultCompileItems>, which I really don't want to.
Out of curiosity, I added a new migration, and I noticed that it updated the .csproj file with the new resource file, but instead of Include it used Update on the EmbeddedResource. I re-introduced manually all of the migrations with Update and then both EF and VS were happy and running Update-Database works.
I saw this issue #1245 and #1234 but couldn't get much out of it. When I add a new migration, I don't get the "generic" glob pattern added, but instead the exact migration.
I have created a repro, where you can see the issue. The repro contains 4 migrations in it.
https://github.com/joaopgrassi/ef63netfx-sdkstyle-migrations (you can check the commit history to see the steps I made)
Update-Database -ConnectionString "Data Source=(LocalDb)\MSSQLLocalDB;Initial Catalog=MoviesDb;Integrated Security=SSPI" -ConnectionProviderName "System.Data.SqlClient" -StartUpProjectName "EFDemo.Data" -ProjectName "EFDemo.Data" -Verbose
It will fail with the error above. To fix it, uncomment the resources in .csproj file. The command will work now.
After being able to create the database, try making any change to the Movie entity and add a new migration:
Add-Migration -Name NewMigration -ConnectionString "Data Source=(LocalDb)\MSSQLLocalDB;Initial Catalog=MoviesDb;Integrated Security=SSPI" -ConnectionProviderName "System.Data.SqlClient" -StartUpProject "EFDemo.Data" -ProjectName "EFDemo.Data" -Verbose
.csproj file. This will be added: <ItemGroup>
<EmbeddedResource Update="Migrations\201909171132226_NewMigration.resx">
<DependentUpon>201909171132226_NewMigration.cs</DependentUpon>
</EmbeddedResource>
</ItemGroup>
EF version: 6.3.0-rc1-19458-04
Database Provider: EntityFramework.SqlServer
Operating system: Windows 10
IDE: Visual Studio 2019 Enterprise v16.2.5
You're mostly hitting https://github.com/aspnet/EntityFramework6/issues/1258#issuecomment-531355034
@bricelam just tried the workaround you suggested on #1258 and still doesn't work. Same error. I guess now I'm hitting https://github.com/microsoft/msbuild/issues/4695 as you mentioned? Any way out of this?
You can download a daily build of the 3.0 SDK: https://github.com/dotnet/core-sdk/blob/master/README.md
@bricelam still doesn't work :(
Running now will all the latest bits:
EntityFramework: 6.5.0-alpha1-19468-01
.NET Core SDK: 5.0.100-alpha1-014711
Visual Studio 2019 16.2.5.
The Update-Database command with -Verbose outputs this:
PM> Update-Database -ConnectionString "Data Source=(LocalDb)\MSSQLLocalDB;Initial Catalog=MoviesDb;Integrated Security=SSPI" -ConnectionProviderName "System.Data.SqlClient" -StartUpProjectName "EFDemo.Data" -ProjectName "EFDemo.Data" -Verbose
C:\Users\JoaoPaoloGrassi\.nuget\packages\entityframework\6.5.0-alpha1-19468-01\tools\net45\any\ef6.exe database update --connection-string "Data Source=(LocalDb)\MSSQLLocalDB;Initial Catalog=MoviesDb;Integrated Security=SSPI" --connection-provider System.Data.SqlClient --verbose --no-color --prefix-output --assembly C:\github\joao\ef63netfx-sdkstyle-migrations\src\EFDemo.Data\bin\Debug\net472\EFDemo.Data.dll --project-dir C:\github\joao\ef63netfx-sdkstyle-migrations\src\EFDemo.Data\ --language C# --root-namespace EFDemo.Data --config C:\github\joao\ef63netfx-sdkstyle-migrations\src\EFDemo.Data\App.config
Specify the '-Verbose' flag to view the SQL statements being applied to the target database.
Target database is: 'MoviesDb' (DataSource: (LocalDb)\MSSQLLocalDB, Provider: System.Data.SqlClient, Origin: Explicit).
Applying explicit migrations: [201909170903584_Init, 201909170929315_ReleaseYearField, 201909170937318_RatingField, 201909170951021_LengthField].
Applying explicit migration: 201909170903584_Init.
System.Resources.MissingManifestResourceException: Could not find any resources appropriate for the specified culture or the neutral culture. Make sure "EFDemo.Data.Migrations.Init.resources" was correctly embedded or linked into assembly "EFDemo.Data" at compile time, or that all the satellite assemblies required are loadable and fully signed.
at System.Resources.ManifestBasedResourceGroveler.HandleResourceStreamMissing(String fileName)
at System.Resources.ManifestBasedResourceGroveler.GrovelForResourceSet(CultureInfo culture, Dictionary`2 localResourceSets, Boolean tryParents, Boolean createIfNotExists, StackCrawlMark& stackMark)
at System.Resources.ResourceManager.InternalGetResourceSet(CultureInfo requestedCulture, Boolean createIfNotExists, Boolean tryParents, StackCrawlMark& stackMark)
at System.Resources.ResourceManager.InternalGetResourceSet(CultureInfo culture, Boolean createIfNotExists, Boolean tryParents)
at System.Resources.ResourceManager.GetString(String name, CultureInfo culture)
at EFDemo.Data.Migrations.Init.System.Data.Entity.Migrations.Infrastructure.IMigrationMetadata.get_Target()
at System.Data.Entity.Migrations.DbMigration.GetModel(Func`2 modelAccessor)
at System.Data.Entity.Migrations.DbMigrator.ApplyMigration(DbMigration migration, DbMigration lastMigration)
at System.Data.Entity.Migrations.Infrastructure.MigratorLoggingDecorator.ApplyMigration(DbMigration migration, DbMigration lastMigration)
at System.Data.Entity.Migrations.DbMigrator.Upgrade(IEnumerable`1 pendingMigrations, String targetMigrationId, String lastMigrationId)
at System.Data.Entity.Migrations.Infrastructure.MigratorLoggingDecorator.Upgrade(IEnumerable`1 pendingMigrations, String targetMigrationId, String lastMigrationId)
at System.Data.Entity.Migrations.DbMigrator.UpdateInternal(String targetMigration)
at System.Data.Entity.Migrations.DbMigrator.EnsureDatabaseExists(Action mustSucceedToKeepDatabase)
at System.Data.Entity.Migrations.DbMigrator.Update(String targetMigration)
at System.Data.Entity.Infrastructure.Design.Executor.Update.<>c__DisplayClass0_0.<.ctor>b__0()
at System.Data.Entity.Infrastructure.Design.Executor.OperationBase.Execute(Action action)
Could not find any resources appropriate for the specified culture or the neutral culture. Make sure "EFDemo.Data.Migrations.Init.resources" was correctly embedded or linked into assembly "EFDemo.Data" at compile time, or that all the satellite assemblies required are loadable and fully signed.
This is what I have on the .csproj file for the EF class library
<Project Sdk="Microsoft.NET.Sdk">
<PropertyGroup>
<TargetFramework>net472</TargetFramework>
</PropertyGroup>
<ItemGroup>
<Folder Include="Properties\" />
</ItemGroup>
<ItemGroup>
<PackageReference Include="EntityFramework" Version="6.5.0-alpha1-19468-01" />
<PackageReference Include="Microsoft.CSharp" Version="4.*" />
</ItemGroup>
<PropertyGroup> <EmbeddedResourceUseDependentUponConvention>true</EmbeddedResourceUseDependentUponConvention>
</PropertyGroup>
</Project>
The changes may not have been merged to 5.0 yet. Use the latest .NET Core 3.0 and EF 6.3 builds
Hi @bricelam, sorry again but I'm still stuck at this. Either I'm doing something terribly wrong or it's not really working. I tried with different daily .NET Core 3.x SDK builds, (Release/3.0.1XX, Release/3.0.100-preview9, Release/3.1.1XX), and multiple different ones from EF 6.3 and it didn't work. Today, I just uninstalled everything and installed the official .NET Core SDK 3.0 and EF 6.3 and it also didn't work. :(
There are so many versions there that I'm just confused at this point. Maybe if you could pinpoint me to one exact version you believe it _should_ work, that would be wonderful
Actually, scratch all that. I updated my VS to 16.3.0 and now everything seems to work just fine. So:
Was VS the problem all along or? 馃槗
Well, now I know that VS is really the problem. Our builds fail now on Azure Pipelines using the Windows-Hosted agent which runs VisualStudio/16.2.0+29123.88 with the same issue I had before: System.Resources.MissingManifestResourceException
We have a set of integration tests using localdb, which calls Database.Create() when the whole test suit starts.
Guess I'll have to wait for Azure DevOps to update their images. Just posting here so anyone else hits the same issue.
Was VS the problem all along
Yes, it was a bug in MSBuild
Most helpful comment
Yes, it was a bug in MSBuild