Can't Enable-Migrations targeting netcoreapp3.0
See original GitHub issueSteps 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:
- Created 4 years ago
- Comments:6 (5 by maintainers)
Top 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 >
Top Related Medium Post
No results found
Top Related StackOverflow Question
No results found
Troubleshoot Live Code
Lightrun enables developers to add logs, metrics and snapshots to live code - no restarts or redeploys required.
Start Free
Top Related Reddit Thread
No results found
Top Related Hackernoon Post
No results found
Top Related Tweet
No results found
Top Related Dev.to Post
No results found
Top Related Hashnode Post
No results found
Thanks Brice. Closing this as won’y fix, since the workaround is easy.
@centreboard @bricelam I think this only happens when the project/solution is called “Ef6”. I renamed it all to “NotSix” and it started working.