From 5ffa5a3fcd3991709fe45d80d83f5c6657aaba02 Mon Sep 17 00:00:00 2001 From: Erik Ejlskov Jensen Date: Wed, 25 Oct 2023 14:27:33 +0200 Subject: [PATCH] Hide reverse engineer option on a MsBuild SqlProj project Only show EF Core 8 option on .NET 8 projects fixes #1979 --- src/GUI/EFCorePowerTools/EFCorePowerToolsPackage.cs | 3 ++- src/GUI/Shared/Extensions/ProjectExtensions.cs | 12 ++++++++++++ src/GUI/Shared/Helpers/ReverseEngineerHelper.cs | 4 ++++ 3 files changed, 18 insertions(+), 1 deletion(-) diff --git a/src/GUI/EFCorePowerTools/EFCorePowerToolsPackage.cs b/src/GUI/EFCorePowerTools/EFCorePowerToolsPackage.cs index 94def00bc..8185e4730 100644 --- a/src/GUI/EFCorePowerTools/EFCorePowerToolsPackage.cs +++ b/src/GUI/EFCorePowerTools/EFCorePowerToolsPackage.cs @@ -356,7 +356,8 @@ private async void OnProjectMenuBeforeQueryStatus(object sender, EventArgs e) if (menuCommand.CommandID.ID == PkgCmdIDList.cmdidReverseEngineerCodeFirst || menuCommand.CommandID.ID == PkgCmdIDList.cmdidT4Drop) { - menuCommand.Visible = await project.IsNet60OrHigherAsync() || await project.IsNetStandardAsync(); + menuCommand.Visible = (await project.IsNet60OrHigherAsync() || await project.IsNetStandardAsync()) + && !project.IsMsBuildSqlProjProject(); return; } diff --git a/src/GUI/Shared/Extensions/ProjectExtensions.cs b/src/GUI/Shared/Extensions/ProjectExtensions.cs index d212061ab..6396b8b35 100644 --- a/src/GUI/Shared/Extensions/ProjectExtensions.cs +++ b/src/GUI/Shared/Extensions/ProjectExtensions.cs @@ -165,6 +165,11 @@ public static async Task GetEFCoreVersionHintAsync(this Project project version = new Version(6, 0); } + if (await project.IsNet80Async()) + { + version = new Version(8, 0); + } + return version; } @@ -217,6 +222,13 @@ public static async Task IsNet70OnlyAsync(this Project project) return IsNet70(targetFrameworkMonikers); } + public static async Task IsNet80Async(this Project project) + { + var targetFrameworkMonikers = await GetTargetFrameworkMonikersAsync(project); + + return IsNet80(targetFrameworkMonikers); + } + public static async Task IsNetStandardAsync(this Project project) { var targetFrameworkMonikers = await GetTargetFrameworkMonikersAsync(project); diff --git a/src/GUI/Shared/Helpers/ReverseEngineerHelper.cs b/src/GUI/Shared/Helpers/ReverseEngineerHelper.cs index fa242a0fb..4f8d0fdc8 100644 --- a/src/GUI/Shared/Helpers/ReverseEngineerHelper.cs +++ b/src/GUI/Shared/Helpers/ReverseEngineerHelper.cs @@ -134,6 +134,10 @@ public string DropTemplates(string optionsPath, string projectPath, CodeGenerati { list.Add(new CodeGenerationItem { Key = (int)CodeGenerationMode.EFCore7, Value = "EF Core 7" }); list.Add(new CodeGenerationItem { Key = (int)CodeGenerationMode.EFCore6, Value = "EF Core 6" }); + } + + if (minimumVersion.Major == 8) + { list.Add(new CodeGenerationItem { Key = (int)CodeGenerationMode.EFCore8, Value = "EF Core 8 (preview)" }); }