Using EF core and EF6 side-by-side

ef-core-3.0 entity-framework entity-framework-6

Question

I have a .NET Core 3.0 solution that contains 5 projects. One of the projects uses EF6, and another one uses EF Core, so EF6 and EF Core are being used side-by-side. Visual Studio is as fresh as possible (16.3.5). Trying to create migration for the project that uses EF6 and executing the Add-Migration command on my laptop with Windows 10 I see a warning message: "Both Entity Framework 6 and Entity Framework Core are installed. The Entity Framework 6 tools are running. Use 'EntityFrameworkCore\Update-Database' for Entity Framework Core", but all goes fine and migration completes successfully.

The Get-Module command displays the following table:

---------- -------    ----                                ----------------                                                                            
Script     6.3.0      EntityFramework6                    {Add-EFDefaultConnectionFactory, Add-EFProvider, Add-Migration, Enable-Migrations...}
Script     3.0.0      EntityFrameworkCore                 {Add-Migration, Drop-Database, Enable-Migrations, Get-DbContext...}
Script     2.0.0.0    NuGet                               {Add-BindingRedirect, Find-Package, Get-Package, Get-Project...}
Script     0.0        profile

On another workstation with Windows 7 onboard, running the same command I see almost the same table but with empty list of cmdlets exported by EF6:

---------- -------    ----                                ----------------                                                                            
Script     6.3.0      EntityFramework6                    
Script     3.0.0      EntityFrameworkCore                 {Add-Migration, Drop-Database, Enable-Migrations, Get-DbContext...}
Script     2.0.0.0    NuGet                               {Add-BindingRedirect, Find-Package, Get-Package, Get-Project...}
Script     0.0        profile 

Eventually, in such a case I can't perform migrations on EF6-bound project at all. How could I fix that? Neither 'Add-Migration' nor 'EntityFramework\Add-Migration' nor 'EntityFrameworkCore\Add-Migration' won't work.

UPDATE 17 oct 2019 That seems to me that my VS installation is corrupted. The good news is that EF6.3 comes with the ef.exe utility that replaces migrate.exe and allows a developer to create migrations using command line outside VS IDE.

1
2
10/17/2019 9:53:26 AM

Popular Answer

Create an additional solution(s) with only your EF6 or only your EFCore dependent project(s) and do what version-specific actions need to be done while using that solution.

0
10/16/2019 7:20:53 PM


Related Questions





Related

Licensed under: CC-BY-SA with attribution
Not affiliated with Stack Overflow
Licensed under: CC-BY-SA with attribution
Not affiliated with Stack Overflow