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

Closes #543 Add generate option for data mapping classes #544

Open
wants to merge 1 commit into
base: master
Choose a base branch
from
Open
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
3 changes: 3 additions & 0 deletions src/EntityFrameworkCore.Generator.Core/CodeGenerator.cs
Original file line number Diff line number Diff line change
Expand Up @@ -90,6 +90,9 @@ private void GenerateQueryExtensions(EntityContext entityContext)

private void GenerateMappingClasses(EntityContext entityContext)
{
if (!Options.Data.Mapping.Generate)
return;

foreach (var entity in entityContext.Entities)
{
Options.Variables.Set(entity);
Expand Down
1 change: 1 addition & 0 deletions src/EntityFrameworkCore.Generator.Core/OptionMapper.cs
Original file line number Diff line number Diff line change
Expand Up @@ -143,6 +143,7 @@ private static void MapMapping(MappingClassOptions option, MappingClass mapping)
{
MapClassBase(option, mapping);

option.Generate = mapping.Generate;
option.Temporal = mapping.Temporal;
option.RowVersion = mapping.RowVersion;
}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -17,8 +17,18 @@ public MappingClassOptions(VariableDictionary variables, string prefix)
Namespace = "{Project.Namespace}.Data.Mapping";
Directory = @"{Project.Directory}\Data\Mapping";
Name = "{Entity.Name}Map";

Generate = true;
}

/// <summary>
/// Gets or sets a value indicating whether this option is generated.
/// </summary>
/// <value>
/// <c>true</c> to generate; otherwise, <c>false</c>.
/// </value>
public bool Generate { get; set; }

/// <summary>
/// Gets or sets if temporal table mapping is enabled. Default true
/// </summary>
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -19,6 +19,15 @@ public MappingClass()
Name = "{Entity.Name}Map";
}

/// <summary>
/// Gets or sets a value indicating whether this option is generated.
/// </summary>
/// <value>
/// <c>true</c> to generate; otherwise, <c>false</c>.
/// </value>
[DefaultValue(true)]
public bool Generate { get; set; } = true;

/// <summary>
/// Gets or sets if temporal table mapping is enabled. Default true
/// </summary>
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -40,6 +40,7 @@ data:
properties:
- ^{Table.Name}(?=Id|Name)
mapping:
generate: true
namespace: '{Project.Namespace}.Data.Mapping'
directory: '{Project.Directory}\Data\Mapping'
document: false
Expand Down