Skip to content

Commit

Permalink
Hide reverse engineer option on a MsBuild SqlProj project
Browse files Browse the repository at this point in the history
Only show EF Core 8 option on .NET 8 projects

fixes #1979
  • Loading branch information
ErikEJ committed Oct 25, 2023
1 parent 4ae093f commit 5ffa5a3
Show file tree
Hide file tree
Showing 3 changed files with 18 additions and 1 deletion.
3 changes: 2 additions & 1 deletion src/GUI/EFCorePowerTools/EFCorePowerToolsPackage.cs
Original file line number Diff line number Diff line change
Expand Up @@ -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;
}

Expand Down
12 changes: 12 additions & 0 deletions src/GUI/Shared/Extensions/ProjectExtensions.cs
Original file line number Diff line number Diff line change
Expand Up @@ -165,6 +165,11 @@ public static async Task<Version> GetEFCoreVersionHintAsync(this Project project
version = new Version(6, 0);
}

if (await project.IsNet80Async())
{
version = new Version(8, 0);
}

return version;
}

Expand Down Expand Up @@ -217,6 +222,13 @@ public static async Task<bool> IsNet70OnlyAsync(this Project project)
return IsNet70(targetFrameworkMonikers);
}

public static async Task<bool> IsNet80Async(this Project project)
{
var targetFrameworkMonikers = await GetTargetFrameworkMonikersAsync(project);

return IsNet80(targetFrameworkMonikers);
}

public static async Task<bool> IsNetStandardAsync(this Project project)
{
var targetFrameworkMonikers = await GetTargetFrameworkMonikersAsync(project);
Expand Down
4 changes: 4 additions & 0 deletions src/GUI/Shared/Helpers/ReverseEngineerHelper.cs
Original file line number Diff line number Diff line change
Expand Up @@ -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)" });
}

Expand Down

0 comments on commit 5ffa5a3

Please sign in to comment.