EF Core cannot create migrations under specific conditions #1464
Labels
area-Meta
backlog-cleanup-candidate
An inactive issue that has been marked for automated closure.
no-recent-activity
tracking-external-issue
The issue is caused by external problem (e.g. OS) - nothing we can do to fix it directly
Milestone
Using EF Core 2.2.6 in a .NET Core 3.0 project, the
dotnet ef migrations
commands may fail with an unexpected exception related to not finding the appropriate version of System.ComponentModel.Annotations. The issue prevents any use of migrations via thedotnet
tooling, but does not prevent migrations from running via the application itself (MigrateAsync()
).The issue is relatively rare, but an extremely annoying issue for projects with the layout that causes the problem.
In short, given the following:
netcoreapp2.2;netcoreapp3.0
netcoreapp2.2;netcoreapp3.0
ProjectReference
to A2PackageReference
toMicrosoft.EntityFrameworkCore.Design, 2.2.6
System.ComponentModel.DataAnnotations
then, any
dotnet ef migrations
commands that run in anetcoreapp3.0
context will fail to run, producing the following error: https://gist.github.com/Nihlus/330279348697561a7002b2972ee54bbeCommands running in a
netcoreapp2.2
context succeed, and are not affected.Steps to reproduce
An example project with minimal reproductions has been created, and is available at https://github.com/Nihlus/EFCore.Repro.
The
master
branch represents the project in a reproducing state, wheredotnet ef
commands fail. The branchesrepro-1
andrepro-2
represent two permutations of non-reproducing states, where the required conditions for the problem are not met.repro-1
- removes the attribute from System.ComponentModel.DataAnnotations from the property in Erepro-2
- referencesMicrosoft.EntityFrameworkCore.Design, 2.2.6
directly from A1To reproduce the issue locally, do the following:
dotnet build
dotnet ef migrations add Test --framework netcoreapp3.0
To see the non-reproducing permutations, check out the relevant branch and repeat from step 2.
Further technical details
EF Core version: 2.2.6
Database provider: Microsoft.EntityFrameworkCore.Sqlite 2.2.6
Operating system: Linux Mint 19.3 (Ubuntu 18.04)
Target framework: .
IDE:
The text was updated successfully, but these errors were encountered: