Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Add UI for option to avoid nullable bools #670

Merged
merged 1 commit into from
Dec 18, 2020
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
12 changes: 12 additions & 0 deletions src/GUI/EFCorePowerTools.Shared/Models/ModelingOptionsModel.cs
Original file line number Diff line number Diff line change
Expand Up @@ -29,6 +29,7 @@ public class ModelingOptionsModel : INotifyPropertyChanged
private bool _mapSpatialTypes;
private bool _mapNodaTimeTypes;
private bool _useEf6Pluralizer;
private bool _useBoolPropertiesWithoutDefaultSql;

public bool UseDataAnnotations
{
Expand Down Expand Up @@ -250,6 +251,17 @@ public bool UseEf6Pluralizer
}
}

public bool UseBoolPropertiesWithoutDefaultSql
{
get => _useBoolPropertiesWithoutDefaultSql;
set
{
if (value == _useBoolPropertiesWithoutDefaultSql) return;
_useBoolPropertiesWithoutDefaultSql = value;
OnPropertyChanged();
}
}

public event PropertyChangedEventHandler PropertyChanged;

[NotifyPropertyChangedInvocator]
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -62,6 +62,11 @@
Content="Use EF6 pluralizer"
IsChecked="{Binding Model.UseEf6Pluralizer}"
Style="{StaticResource MarginCheckBlockStyle}"/>

<CheckBox TabIndex="5"
Content="Remove default constraint from bool columns"
IsChecked="{Binding Model.UseBoolPropertiesWithoutDefaultSql}"
Style="{StaticResource MarginCheckBlockStyle}"/>
</StackPanel>

<StackPanel Grid.Row="20"
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -45,6 +45,7 @@ public static ReverseEngineerResult LaunchExternalRunner(ReverseEngineerOptions
UseSpatial = options.UseSpatial,
UseDbContextSplitting = options.UseDbContextSplitting,
UseNodaTime = options.UseNodaTime,
UseBoolPropertiesWithoutDefaultSql = options.UseBoolPropertiesWithoutDefaultSql,
};

var launcher = new ReverseEngineer20.ReverseEngineer.EfRevEngLauncher(commandOptions, useEFCore5);
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -40,6 +40,7 @@ public class ReverseEngineerOptions
public bool UseDbContextSplitting { get; set; }
public bool UseNodaTime { get; set; }
public bool FilterSchemas { get; set; }
public bool UseBoolPropertiesWithoutDefaultSql { get; set; }
public List<SchemaInfo> Schemas { get; set; }

public static ReverseEngineerOptions FromV1(ReverseEngineerOptionsV1 v1)
Expand Down
4 changes: 3 additions & 1 deletion src/GUI/EFCorePowerTools/Handlers/ReverseEngineerHandler.cs
Original file line number Diff line number Diff line change
Expand Up @@ -198,6 +198,7 @@ public async Task ReverseEngineerCodeFirstAsync(Project project)
presets.UseEf6Pluralizer = options.UseLegacyPluralizer;
presets.MapSpatialTypes = options.UseSpatial;
presets.MapNodaTimeTypes = options.UseNodaTime;
presets.UseBoolPropertiesWithoutDefaultSql = options.UseBoolPropertiesWithoutDefaultSql;
}

var modelDialog = _package.GetView<IModelingOptionsDialog>()
Expand Down Expand Up @@ -230,12 +231,13 @@ public async Task ReverseEngineerCodeFirstAsync(Project project)
SelectedHandlebarsLanguage = modelingOptionsResult.Payload.SelectedHandlebarsLanguage,
IncludeConnectionString = modelingOptionsResult.Payload.IncludeConnectionString,
SelectedToBeGenerated = modelingOptionsResult.Payload.SelectedToBeGenerated,
UseBoolPropertiesWithoutDefaultSql = modelingOptionsResult.Payload.UseBoolPropertiesWithoutDefaultSql,
Dacpac = dacpacPath,
DefaultDacpacSchema = dacpacSchema,
Tables = pickTablesResult.Payload.Objects.ToList(),
CustomReplacers = pickTablesResult.Payload.CustomReplacers.ToList(),
FilterSchemas = filterSchemas,
Schemas = schemas?.ToList()
Schemas = schemas?.ToList(),
};

if (options.DatabaseType == DatabaseType.SQLServer
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -57,6 +57,7 @@ void IAdvancedModelingOptionsViewModel.ApplyPresets(ModelingOptionsModel presets
Model.MapSpatialTypes = presets.MapSpatialTypes;
Model.MapNodaTimeTypes = presets.MapNodaTimeTypes;
Model.UseEf6Pluralizer = presets.UseEf6Pluralizer;
Model.UseBoolPropertiesWithoutDefaultSql = presets.UseBoolPropertiesWithoutDefaultSql;
}
}
}
Original file line number Diff line number Diff line change
Expand Up @@ -133,6 +133,7 @@ private void Advanced_Executed()
Model.MapSpatialTypes = advancedModelingOptionsResult.Payload.MapSpatialTypes;
Model.MapNodaTimeTypes = advancedModelingOptionsResult.Payload.MapNodaTimeTypes;
Model.UseEf6Pluralizer = advancedModelingOptionsResult.Payload.UseEf6Pluralizer;
Model.UseBoolPropertiesWithoutDefaultSql = advancedModelingOptionsResult.Payload.UseBoolPropertiesWithoutDefaultSql;
}

void IModelingOptionsViewModel.ApplyPresets(ModelingOptionsModel presets)
Expand All @@ -157,6 +158,7 @@ void IModelingOptionsViewModel.ApplyPresets(ModelingOptionsModel presets)
Model.MapSpatialTypes = presets.MapSpatialTypes;
Model.MapNodaTimeTypes = presets.MapNodaTimeTypes;
Model.UseEf6Pluralizer = presets.UseEf6Pluralizer;
Model.UseBoolPropertiesWithoutDefaultSql = presets.UseBoolPropertiesWithoutDefaultSql;

Title = $"Generate EF Core Model in Project {Model.ProjectName}";
}
Expand Down
2 changes: 1 addition & 1 deletion src/GUI/RevEng.Shared/ReverseEngineerCommandOptions.cs
Original file line number Diff line number Diff line change
Expand Up @@ -31,7 +31,7 @@ public class ReverseEngineerCommandOptions
public bool UseSpatial { get; set; }
public bool UseDbContextSplitting { get; set; }
public bool UseNodaTime { get; set; }
public bool UseStoredProcedures { get; set; }
public bool UseBoolPropertiesWithoutDefaultSql { get; set; }
public bool FilterSchemas { get; set; }
public List<SchemaInfo> Schemas { get; set; }
}
Expand Down