Skip to content

Commit 85da380

Browse files
committed
Rename OverridePropertyNaming. Fixes #3
1 parent 934af2a commit 85da380

File tree

4 files changed

+12
-13
lines changed

4 files changed

+12
-13
lines changed

README.md

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -51,7 +51,7 @@ The two extension methods in the `OnModelCreating` method in the `DbContext` cla
5151
- **SetTableNamingSource(...)** defines which naming source to use (see below). It means whether to use the ClrType name or the DbSet name to name the tables.
5252
- **Singularize()** or **Pluralize()** defines whether the table names will be the singular or plural versions.
5353
- **SetNamingScheme(...)** allows you to override the naming using one of the predefined schemes (see below) or a custom function.
54-
- **OverrideTableNaming(...)**, **OverridePropertyNaming(...)**, **OverrideConstraintNaming(...)** to deviate from the general naming scheme.
54+
- **OverrideTableNaming(...)**, **OverrideColumnNaming(...)**, **OverrideConstraintNaming(...)** to deviate from the general naming scheme.
5555
- **SkipEntireEntities(...)** and **SkipTableNamingForEntities(...)** to skip the naming for either the whole entity or just the table name for certain entities by using a `Func<IMutableEntityType, bool>` skip function, e.g. `SkipEntireEntities(entity => entity.Name == "MyEntity")`.
5656
- **SkipTableNamingForGenericEntityTypes()** should be used to avoid naming the Enum lookup tables which can lead to unwanted results.
5757

src/SpatialFocus.EntityFrameworkCore.Extensions/EnumLookupAttribute.cs

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,4 @@
1-
// <copyright file="EnumLockupAttribute.cs" company="Spatial Focus">
1+
// <copyright file="EnumLookupAttribute.cs" company="Spatial Focus">
22
// Copyright (c) Spatial Focus. All rights reserved.
33
// Licensed under the MIT license. See LICENSE file in the project root for full license information.
44
// </copyright>

src/SpatialFocus.EntityFrameworkCore.Extensions/NamingExtension.cs

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -31,7 +31,7 @@ public static void ConfigureNames(this ModelBuilder modelBuilder, NamingOptions
3131
// Properties
3232
entity.GetProperties()
3333
.ToList()
34-
.ForEach(x => x.Relational().ColumnName = namingOptions.PropertyNamingFunction(x.Relational().ColumnName));
34+
.ForEach(x => x.Relational().ColumnName = namingOptions.ColumnNamingFunction(x.Relational().ColumnName));
3535

3636
// Primary and Alternative keys
3737
entity.GetKeys().ToList().ForEach(x => x.Relational().Name = namingOptions.ConstraintNamingFunction(x.Relational().Name));

src/SpatialFocus.EntityFrameworkCore.Extensions/NamingOptions.cs

Lines changed: 9 additions & 10 deletions
Original file line numberDiff line numberDiff line change
@@ -19,7 +19,7 @@ public class NamingOptions
1919

2020
private Func<string, string> postProcessingTableNamingFunction = name => name;
2121

22-
private Func<string, string> propertyNamingFunction;
22+
private Func<string, string> columnNamingFunction;
2323

2424
private Func<string, string> tableNamingFunction;
2525

@@ -46,32 +46,31 @@ internal Func<IMutableEntityType, bool> EntitiesToSkipTableNaming
4646

4747
internal Func<string, string> NamingFunction { get; set; }
4848

49-
internal Func<string, string> PropertyNamingFunction
49+
internal Func<string, string> ColumnNamingFunction
5050
{
51-
get => this.propertyNamingFunction ?? NamingFunction;
52-
set => this.propertyNamingFunction = value;
51+
get => this.columnNamingFunction ?? NamingFunction;
52+
set => this.columnNamingFunction = value;
5353
}
5454

5555
internal Func<IMutableEntityType, string> TableNameSource { get; set; }
5656

5757
internal Func<string, string> TableNamingFunction
5858
{
5959
get =>
60-
name => this.postProcessingTableNamingFunction(this.tableNamingFunction != null
61-
? this.tableNamingFunction(name)
60+
name => this.postProcessingTableNamingFunction(this.tableNamingFunction != null ? this.tableNamingFunction(name)
6261
: NamingFunction(name));
6362
set => this.tableNamingFunction = value;
6463
}
6564

66-
public NamingOptions OverrideConstraintNaming(Func<string, string> namingFunc)
65+
public NamingOptions OverrideColumnNaming(Func<string, string> namingFunc)
6766
{
68-
ConstraintNamingFunction = namingFunc;
67+
ColumnNamingFunction = namingFunc;
6968
return this;
7069
}
7170

72-
public NamingOptions OverridePropertyNaming(Func<string, string> namingFunc)
71+
public NamingOptions OverrideConstraintNaming(Func<string, string> namingFunc)
7372
{
74-
PropertyNamingFunction = namingFunc;
73+
ConstraintNamingFunction = namingFunc;
7574
return this;
7675
}
7776

0 commit comments

Comments
 (0)