question-mark
Stuck on an issue?

Lightrun Answers was designed to reduce the constant googling that comes with debugging 3rd party libraries. It collects links to all the places you might be looking at while hunting down a tough bug.

And, if you’re still stuck at the end, we’re happy to hop on a call to see how we can help out.

Can't Enable-Migrations targeting netcoreapp3.0

See original GitHub issue

Steps to reproduce

With a brand new class library I can’t enable migrations when targeting netcoreapp3.0 . It works if I change to net48 or dual target net48;netcoreapp3.0

PM> Enable-Migrations
Unhandled exception. System.IO.FileLoadException: Could not load file or assembly 'C:\Users\majohnson\.nuget\packages\entityframework\6.3.0\tools\netcoreapp3.0\any\ef6.dll'. The located assembly's manifest definition does not match the assembly reference. (0x80131040)
File name: 'C:\Users\majohnson\.nuget\packages\entityframework\6.3.0\tools\netcoreapp3.0\any\ef6.dll'
<Project Sdk="Microsoft.NET.Sdk">

  <PropertyGroup>
    <TargetFramework>netcoreapp3.0</TargetFramework>
  </PropertyGroup>
  <ItemGroup>
    <PackageReference Include="EntityFramework" Version="6.3.0" />
  </ItemGroup>

</Project>
using System.Data.Entity;
using System.Data.Entity.Infrastructure;

namespace Ef6 {
    
    public class MyContextFactory : IDbContextFactory<MyContext> {
        public MyContext Create() {
            return new MyContext(
                "Server=(localdb)\\mssqllocaldb;Database=MyContext;Trusted_Connection=True;MultipleActiveResultSets=true");
        }
    }
    
    public class MyContext : DbContext {
        public MyContext(string connectionString) : base(connectionString) { }
        
        public DbSet<MyTable> MyTables { get; set; }
    }
    
    public class MyTable {
        public int Id { get; set; }
    }
}

Further technical details

EF version: 6.3 Database Provider: (e.g. EntityFramework.SqlServer) Operating system: (e.g. Windows 10) Windows 10 IDE: (e.g. Visual Studio 2017 15.6) VS 2019 16.4 Preview 1

dotnet --version 3.0.100

Issue Analytics

  • State:closed
  • Created 4 years ago
  • Comments:6 (5 by maintainers)

github_iconTop GitHub Comments

1reaction
ajcvickerscommented, Oct 16, 2019

Thanks Brice. Closing this as won’y fix, since the workaround is easy.

1reaction
ajcvickerscommented, Oct 15, 2019

@centreboard @bricelam I think this only happens when the project/solution is called “Ef6”. I renamed it all to “NotSix” and it started working.

Read more comments on GitHub >

github_iconTop Results From Across the Web

Error while Add-Migration "Initialize" in .NET 6 Entity ...
You can resolve the problem by installing the specified framework and/or SDK. The specified framework can be found at: https://aka.ms/dotnet- ...
Read more >
Can't enable migrations for Entity Framework on VS 2017 . ...
7 Answers. EF Core does not have Enable-Migrations command anymore. Migrations are enabled "by default". Add new migration with Add-Migration .
Read more >
Converting a .NET Standard 2.0 library to .NET Core 3.0
In this post I describe the decisions to make and factors affecting upgrading a typical library targeting .NET Standard 2.0 to .
Read more >
Entity Framework Core Inside Rider: UI Way
Use Tools | Entity Framework Core | Update Database to update the database to the required target migration: The Target migration field is ......
Read more >
Multi-targetting .Net Framework and .Net Core in a single project
The simplest way to do the reverse—to make an older netframework project multi-target—is to first migrate it to a netcore project then carry ......
Read more >

github_iconTop Related Medium Post

No results found

github_iconTop Related StackOverflow Question

No results found

github_iconTroubleshoot Live Code

Lightrun enables developers to add logs, metrics and snapshots to live code - no restarts or redeploys required.
Start Free

github_iconTop Related Reddit Thread

No results found

github_iconTop Related Hackernoon Post

No results found

github_iconTop Related Tweet

No results found

github_iconTop Related Dev.to Post

No results found

github_iconTop Related Hashnode Post

No results found