Skip to content

Commit

Permalink
add missing EfCore.Tools package to dotnet-scaffold-aspnet scaffolder…
Browse files Browse the repository at this point in the history
…s. (#3040)

* add missing EfCore.Tools package to dotnet-scaffold-aspnet scaffolders.

* minor fix for 'minimalapi' scaffolder
  • Loading branch information
deepchoudhery authored Oct 23, 2024
1 parent e2d8330 commit b8e1321
Show file tree
Hide file tree
Showing 4 changed files with 8 additions and 5 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -49,7 +49,8 @@ public static IScaffoldBuilder WithBlazorCrudAddPackagesStep(this IScaffoldBuild
var packageList = new List<string>()
{
PackageConstants.AspNetCorePackages.QuickGridEfAdapterPackageName,
PackageConstants.AspNetCorePackages.AspNetCoreDiagnosticsEfCorePackageName
PackageConstants.AspNetCorePackages.AspNetCoreDiagnosticsEfCorePackageName,
PackageConstants.EfConstants.EfCoreToolsPackageName
};
if (context.Properties.TryGetValue(nameof(CrudSettings), out var commandSettingsObj) &&
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -46,7 +46,7 @@ public static IScaffoldBuilder WithEfControllerAddPackagesStep(this IScaffoldBui
{
var step = config.Step;
var context = config.Context;
List<string> packageList = [];
List<string> packageList = [PackageConstants.EfConstants.EfCoreToolsPackageName];
if (context.Properties.TryGetValue(nameof(EfControllerSettings), out var commandSettingsObj) &&
commandSettingsObj is EfControllerSettings commandSettings)
{
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -61,16 +61,18 @@ public static IScaffoldBuilder WithMinimalApiAddPackagesStep(this IScaffoldBuild
{
var step = config.Step;
var context = config.Context;
//add Microsoft.EntityFrameworkCore.Tools package regardless of the DatabaseProvider
//this scaffolder has a non-EF scenario, only add EF packages if DataContext is provided.
List<string> packageList = [];
if (context.Properties.TryGetValue(nameof(MinimalApiSettings), out var commandSettingsObj) &&
commandSettingsObj is MinimalApiSettings commandSettings)
{
step.ProjectPath = commandSettings.Project;
step.Prerelease = commandSettings.Prerelease;
if (!string.IsNullOrEmpty(commandSettings.DatabaseProvider) &&
if (!string.IsNullOrEmpty(commandSettings.DataContext) &&
!string.IsNullOrEmpty(commandSettings.DatabaseProvider) &&
PackageConstants.EfConstants.EfPackagesDict.TryGetValue(commandSettings.DatabaseProvider, out string? projectPackageName))
{
packageList.Add(PackageConstants.EfConstants.EfCoreToolsPackageName);
packageList.Add(projectPackageName);
}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -84,7 +84,7 @@ public static IScaffoldBuilder WithRazorPagesAddPackagesStep(this IScaffoldBuild
{
var step = config.Step;
var context = config.Context;
List<string> packageList = [];
List<string> packageList = [PackageConstants.EfConstants.EfCoreToolsPackageName];
if (context.Properties.TryGetValue(nameof(CrudSettings), out var commandSettingsObj) &&
commandSettingsObj is CrudSettings commandSettings)
{
Expand Down

0 comments on commit b8e1321

Please sign in to comment.