Closed Uraharadono closed 1 year ago
@Uraharadono If your solution references EF6 and EF Core, then you're get both PowerShell modules loaded by default. If you don't want to fully qualify, then you should be able to unload the EntityFramework6
module after starting the VS Package Manager Console.
@ajcvickers Hey Arthur, thanks a lot for your help. That unfortunately does not work.
After I run:
PM> Remove-Module EntityFramework6
And then try to do add migration, I get following error.
PM> Add-Migration TestMigration
Add-Migration : The term 'Add-Migration' is not recognized as the name of a cmdlet, function, script file, or operable program. Check the spelling of the name, or if a path was included, verify that the path is co
rrect and try again.
At line:1 char:1
+ Add-Migration TestMigration
+ ~~~~~~~~~~~~~
+ CategoryInfo : ObjectNotFound: (Add-Migration:String) [], CommandNotFoundException
+ FullyQualifiedErrorId : CommandNotFoundException
This solution does actually have a lot of projects that are using Entity Framework 6 (EF6) 6.3.0 versions. I guess not much can be done regarding this, than to write fully qualified commands for core...
Edit: Using EntityFrameworkCore\Add-Migration TestMigration
yields same result.
@Uraharadono Can you create a simple solution with a couple of projects (one EF6 and one EF Core) which results in this behavior on your machine? This will let us investigate what is going on here.
Hey @ajcvickers, Sorry for being late. I was very very busy. Here is the link to repo I just created to reproduce this issue: https://github.com/Uraharadono/EFMixIssue
@Uraharadono I am not able to reproduce this:
PM> Add-Migration Test
Both Entity Framework Core and Entity Framework 6 are installed. The Entity Framework Core tools are running. Use 'EntityFramework6\Add-Migration' for Entity Framework 6.
Build started...
Build succeeded.
Your startup project 'EFMixIssue.NetFramework47' doesn't reference Microsoft.EntityFrameworkCore.Design. This package is required for the Entity Framework Core Tools to work. Ensure your startup project is correct, install the package, and try again.
PM> Get-Module
ModuleType Version Name ExportedCommands
---------- ------- ---- ----------------
Script 6.4.4 EntityFramework6 {Add-EFDefaultConnectionFactory, Add-EFProvider, Add-Migration, Enable-Migrations...}
Script 5.0.13 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
PM> Remove-Module EntityFramework6
PM> Add-Migration Test
Build started...
Build succeeded.
Your startup project 'EFMixIssue.NetFramework47' doesn't reference Microsoft.EntityFrameworkCore.Design. This package is required for the Entity Framework Core Tools to work. Ensure your startup project is correct, install the package, and try again.
PM>
What version of Visual Studio are you using?
@ajcvickers First of all I am sorry for troubling you. While I reported this issue I had only 2019. In meantime I have installed and updated both '19 and 22 versions. Now when I try to it in both of them it works for whatever reason.
So I have no idea what I has changed in meantime. Here is my log just for good measure:
PM> Add-Migration TestMigration
Both Entity Framework Core and Entity Framework 6 are installed. The Entity Framework Core tools are running. Use 'EntityFramework6\Add-Migration' for Entity Framework 6.
Build started...
Build succeeded.
To undo this action, use Remove-Migration.
PM> Remove-Migration
Build started...
Build succeeded.
Removing migration '20220128125427_TestMigration'.
Reverting the model snapshot.
Done.
PM> Get-Module
ModuleType Version Name ExportedCommands
---------- ------- ---- ----------------
Script 6.4.4 EntityFramework6 {Add-EFDefaultConnectionFactory, Add-EFProvider, Add-Migration, Enable-Migrations...}
Script 5.0.13 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
PM> Remove-Module EntityFramework6
PM> Add-Migration TestMigration
Build started...
Build succeeded.
To undo this action, use Remove-Migration.
PM> Get-Module
ModuleType Version Name ExportedCommands
---------- ------- ---- ----------------
Script 5.0.13 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
I am once again sorry for all the inconvenience, and I am very thankful for your selfless help. I wish you all the best, and hopefully I report next time something more meaningful and productive.
What's the solution to this now? I have the same problem that I removed EF6 and cannot add migrations anymore for EfCore...
@garcipat Please open a new issue and include full details of what you are trying to do, what commands you are running, and any errors that are generated.
@ajcvickers Sorry for commenting here as you closed this issue. Since our last time we spoke I got mentioned problem couple of times as well. I am commenting here as @garcipat is having same issue I reported before.
I figured it happens mostly if tools default to Entity Framework 6. So, when message is
Both Entity Framework Core and Entity Framework 6 are installed. The Entity Framework 6 tools are running. Use 'EntityFrameworkCore\Add-Migration' for Entity Framework Core.
Build Failed.
so if we do our set of commands we discussed before:
PM> Remove-Module EntityFramework6
PM> Add-Migration TestMigration
Add-Migration : The term 'Add-Migration' is not recognized as the name of a cmdlet, function, script file, or operable program. Check the spelling of the name, or if a path was included, verify that the path is co
rrect and try again.
I cannot produce this bug consistently as from what I gather default Migration tools are selected randomly on project startup. I mean, this is just a inconvenience and not a real bug. And it happens so randomly, but I can attest it is there.
I have the same exact bug. Please reopen the issue
@sparrow58 please open a new issue with the full project and repro steps - as you can see above the issue could not be reproduced.
in my case, my project was referencing linqkit which uses EF6, just change to linqkit.core
Hello everyone,
I have my DbContext in .Net 5 class library. When I try to run migration I get message:
I know I can run my migration like so:
EntityFrameworkCore\Add-Migration TestMigration
but I would really hate this approach, and would love if I could only type in Add-Migration. I don't want to use Entity Framework 6 and I would like Entity Framework Core to be only installed version of Entity Framework.
How can I remove the 6 one only?
Here is my .csproj file:
Edit 1: Edit: I have uninstalled the
<PackageReference Include="Microsoft.EntityFrameworkCore" Version="5.0.10" />
Problem still persists.Edit 2: I think I have messed up by installing the https://docs.microsoft.com/en-us/ef/core/cli/dotnet globally.
But when I run
dotnet ef
command in CMD as admin or in PMC I get error:Edit 3: When I run command in Package Manager Console:
Get-Module
I get: