簡體   English   中英

添加遷移 - Entity Framework Core 和 Entity Framework 6 都已安裝

[英]Add migration - Both Entity Framework Core and Entity Framework 6 are installed

我有一個包含多個項目的解決方案,其中一個使用 EF 6,另一個使用 entityframeworkcore。

在添加 EF6 項目之前,遷移工作正常,但現在我無法使用遷移的命令: add-migration 'anything'<\/code>

Entity Framework Core 和 Entity Framework 6 都已安裝。 Entity Framework Core 工具正在運行。 對實體框架 6 使用“EntityFramework\\Add-Migration”。

對於使用 EF6 的項目,我可以使用這種方式添加遷移: EntityFramework\\Add-Migration 'anthing_here'<\/code> ,但我無法使用這種方式向使用 EFCore 的項目添加遷移。

有什么建議 ??

對於 EF6:

EntityFramework\Add-Migration <MIGRATIONNAME>

對於 EF 核心:

EntityFrameworkCore\Add-Migration <MIGRATIONNAME>

我在我們的項目中也發生了同樣的情況,該項目已經有 20 年的歷史了。

它擁有從Web 表單<\/strong>到最新的.Net Core<\/strong>技術的所有內容。 取決於運氣,我有時會發現PackageManagerConsole<\/code>有時使用EFCore<\/code> EF6<\/code>

我很不高興我不得不使用上述答案中的前綴,所以我挖得更深。

如果您在PM> PackageManagerConsole<\/code>中運行命令Get-Module<\/code> ,您應該獲得活動模塊的列表:

ModuleType Version    Name                                ExportedCommands                                                                                                                                                                                                
---------- -------    ----                                ----------------                                                                                                                                                                                                
Script     6.4.4      EntityFramework6                    {Add-EFDefaultConnectionFactory, Add-EFProvider, Add-Migration, Enable-Migrations...}                                                                                                                           
Script     5.0.10     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             

暫無
暫無

聲明:本站的技術帖子網頁,遵循CC BY-SA 4.0協議,如果您需要轉載,請注明本站網址或者原文地址。任何問題請咨詢:yoyou2525@163.com.

 
粵ICP備18138465號  © 2020-2024 STACKOOM.COM