Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

EF Core cannot create migrations under specific conditions #1464

Open
Nihlus opened this issue Dec 30, 2019 · 3 comments
Open

EF Core cannot create migrations under specific conditions #1464

Nihlus opened this issue Dec 30, 2019 · 3 comments
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

Comments

@Nihlus
Copy link

Nihlus commented Dec 30, 2019

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 the dotnet 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:

  • Let A1 be an assembly targeting netcoreapp2.2;netcoreapp3.0
  • Let A2 be an assembly targeting netcoreapp2.2;netcoreapp3.0
  • Let A1 have a ProjectReference to A2
  • Let A2 have a PackageReference to Microsoft.EntityFrameworkCore.Design, 2.2.6
  • Let C be a database context defined in A1
  • Let E be a database entity defined in A1
  • Let E have at least one public property that uses an attribute from
    System.ComponentModel.DataAnnotations

then, any dotnet ef migrations commands that run in a netcoreapp3.0 context will fail to run, producing the following error: https://gist.github.com/Nihlus/330279348697561a7002b2972ee54bbe

Commands 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, where dotnet ef commands fail. The branches repro-1 and repro-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 E
  • repro-2 - references Microsoft.EntityFrameworkCore.Design, 2.2.6 directly from A1

To reproduce the issue locally, do the following:

  1. Clone the above repository
  2. Run dotnet build
  3. Run 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: .

  • .NET Core 3.0
  • .NET Core 2.2

IDE:

  • JetBrains Rider 2019.3.1
  • No IDE
@ajcvickers ajcvickers transferred this issue from dotnet/efcore Jan 8, 2020
@Dotnet-GitSync-Bot Dotnet-GitSync-Bot added area-Meta untriaged New issue has not been triaged by the area owner labels Jan 8, 2020
@ajcvickers
Copy link
Contributor

This looks like another example of https://github.com/dotnet/corefx/issues/33643

@joperezr
Copy link
Member

joperezr commented Mar 3, 2020

The problem here seems to be more specific to the ef migrations command which is not really developed in this repo, so I think that a better place for an issue like this would be https://github.com/dotnet/aspnetcore-tooling. Do you mind openning the issue there so that the right people get engaged and look into this?

@joperezr joperezr added tracking-external-issue The issue is caused by external problem (e.g. OS) - nothing we can do to fix it directly and removed untriaged New issue has not been triaged by the area owner labels Jul 7, 2020
@joperezr joperezr added this to the Future milestone Jul 7, 2020
MichalStrehovsky added a commit to MichalStrehovsky/runtime that referenced this issue Dec 9, 2021
Match CoreCLR behavior and prevent compiler from crashing

Co-authored-by: Michal Strehovský <[email protected]>
Copy link
Contributor

Due to lack of recent activity, this issue has been marked as a candidate for backlog cleanup. It will be closed if no further activity occurs within 14 more days. Any new comment (by anyone, not necessarily the author) will undo this process.

This process is part of our issue cleanup automation.

@dotnet-policy-service dotnet-policy-service bot added backlog-cleanup-candidate An inactive issue that has been marked for automated closure. no-recent-activity labels Jan 6, 2025
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
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
Projects
No open projects
Development

No branches or pull requests

4 participants