diff --git a/src/EntityFrameworkCore.Generator.Core/CodeGenerator.cs b/src/EntityFrameworkCore.Generator.Core/CodeGenerator.cs
index 2d520e7d..f1e3165e 100644
--- a/src/EntityFrameworkCore.Generator.Core/CodeGenerator.cs
+++ b/src/EntityFrameworkCore.Generator.Core/CodeGenerator.cs
@@ -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);
diff --git a/src/EntityFrameworkCore.Generator.Core/OptionMapper.cs b/src/EntityFrameworkCore.Generator.Core/OptionMapper.cs
index ad837307..eb6454c5 100644
--- a/src/EntityFrameworkCore.Generator.Core/OptionMapper.cs
+++ b/src/EntityFrameworkCore.Generator.Core/OptionMapper.cs
@@ -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;
}
diff --git a/src/EntityFrameworkCore.Generator.Core/Options/MappingClassOptions.cs b/src/EntityFrameworkCore.Generator.Core/Options/MappingClassOptions.cs
index c5ad6fc1..1c353007 100644
--- a/src/EntityFrameworkCore.Generator.Core/Options/MappingClassOptions.cs
+++ b/src/EntityFrameworkCore.Generator.Core/Options/MappingClassOptions.cs
@@ -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;
}
+ ///
+ /// Gets or sets a value indicating whether this option is generated.
+ ///
+ ///
+ /// true to generate; otherwise, false.
+ ///
+ public bool Generate { get; set; }
+
///
/// Gets or sets if temporal table mapping is enabled. Default true
///
diff --git a/src/EntityFrameworkCore.Generator.Core/Serialization/MappingClass.cs b/src/EntityFrameworkCore.Generator.Core/Serialization/MappingClass.cs
index b5c4706a..21a0e8ee 100644
--- a/src/EntityFrameworkCore.Generator.Core/Serialization/MappingClass.cs
+++ b/src/EntityFrameworkCore.Generator.Core/Serialization/MappingClass.cs
@@ -19,6 +19,15 @@ public MappingClass()
Name = "{Entity.Name}Map";
}
+ ///
+ /// Gets or sets a value indicating whether this option is generated.
+ ///
+ ///
+ /// true to generate; otherwise, false.
+ ///
+ [DefaultValue(true)]
+ public bool Generate { get; set; } = true;
+
///
/// Gets or sets if temporal table mapping is enabled. Default true
///
diff --git a/test/EntityFrameworkCore.Generator.Core.Tests/Options/full.yaml b/test/EntityFrameworkCore.Generator.Core.Tests/Options/full.yaml
index 5d253569..a97307ad 100644
--- a/test/EntityFrameworkCore.Generator.Core.Tests/Options/full.yaml
+++ b/test/EntityFrameworkCore.Generator.Core.Tests/Options/full.yaml
@@ -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