mirror of
https://github.com/fergalmoran/EFCore.NamingConventions.git
synced 2025-12-22 09:38:21 +00:00
Version 7.0.0-rc.2 (#167)
This commit is contained in:
6
.github/workflows/build.yml
vendored
6
.github/workflows/build.yml
vendored
@@ -4,16 +4,14 @@ on: [push, pull_request]
|
|||||||
|
|
||||||
jobs:
|
jobs:
|
||||||
build:
|
build:
|
||||||
runs-on: ubuntu-20.04
|
runs-on: ubuntu-22.04
|
||||||
|
|
||||||
steps:
|
steps:
|
||||||
- name: Checkout
|
- name: Checkout
|
||||||
uses: actions/checkout@v3
|
uses: actions/checkout@v3
|
||||||
|
|
||||||
- name: Setup .NET Core SDK
|
- name: Setup .NET Core SDK
|
||||||
uses: actions/setup-dotnet@v3.0.2
|
uses: actions/setup-dotnet@v3
|
||||||
with:
|
|
||||||
dotnet-version: '6.0.100-rc.1.21463.6'
|
|
||||||
|
|
||||||
- name: Test
|
- name: Test
|
||||||
run: dotnet test
|
run: dotnet test
|
||||||
|
|||||||
@@ -1,7 +1,7 @@
|
|||||||
<Project>
|
<Project>
|
||||||
<PropertyGroup>
|
<PropertyGroup>
|
||||||
<EFCoreVersion>6.0.10</EFCoreVersion>
|
<EFCoreVersion>7.0.0-rc.2.22472.11</EFCoreVersion>
|
||||||
<MicrosoftExtensionsVersion>6.0.0</MicrosoftExtensionsVersion>
|
<MicrosoftExtensionsVersion>7.0.0-rc.2.22472.3</MicrosoftExtensionsVersion>
|
||||||
</PropertyGroup>
|
</PropertyGroup>
|
||||||
|
|
||||||
<ItemGroup>
|
<ItemGroup>
|
||||||
|
|||||||
@@ -1,7 +1,7 @@
|
|||||||
<Project Sdk="Microsoft.NET.Sdk">
|
<Project Sdk="Microsoft.NET.Sdk">
|
||||||
|
|
||||||
<PropertyGroup>
|
<PropertyGroup>
|
||||||
<TargetFramework>net6.0</TargetFramework>
|
<TargetFramework>net7.0</TargetFramework>
|
||||||
</PropertyGroup>
|
</PropertyGroup>
|
||||||
|
|
||||||
<ItemGroup>
|
<ItemGroup>
|
||||||
|
|||||||
@@ -17,7 +17,7 @@ public class SqliteTestHelpers : TestHelpers
|
|||||||
public override IServiceCollection AddProviderServices(IServiceCollection services)
|
public override IServiceCollection AddProviderServices(IServiceCollection services)
|
||||||
=> services.AddEntityFrameworkSqlite();
|
=> services.AddEntityFrameworkSqlite();
|
||||||
|
|
||||||
public override void UseProviderOptions(DbContextOptionsBuilder optionsBuilder)
|
public override DbContextOptionsBuilder UseProviderOptions(DbContextOptionsBuilder optionsBuilder)
|
||||||
=> optionsBuilder.UseSqlite(new SqliteConnection("Data Source=:memory:"));
|
=> optionsBuilder.UseSqlite(new SqliteConnection("Data Source=:memory:"));
|
||||||
|
|
||||||
#pragma warning disable EF1001
|
#pragma warning disable EF1001
|
||||||
|
|||||||
@@ -9,6 +9,7 @@ ProjectSection(SolutionItems) = preProject
|
|||||||
Directory.Build.props = Directory.Build.props
|
Directory.Build.props = Directory.Build.props
|
||||||
.github\workflows\build.yml = .github\workflows\build.yml
|
.github\workflows\build.yml = .github\workflows\build.yml
|
||||||
Directory.Packages.props = Directory.Packages.props
|
Directory.Packages.props = Directory.Packages.props
|
||||||
|
global.json = global.json
|
||||||
EndProjectSection
|
EndProjectSection
|
||||||
EndProject
|
EndProject
|
||||||
Global
|
Global
|
||||||
|
|||||||
@@ -2,7 +2,7 @@
|
|||||||
|
|
||||||
<PropertyGroup>
|
<PropertyGroup>
|
||||||
<TargetFramework>net6.0</TargetFramework>
|
<TargetFramework>net6.0</TargetFramework>
|
||||||
<VersionPrefix>6.0.0</VersionPrefix>
|
<VersionPrefix>7.0.0-rc.2</VersionPrefix>
|
||||||
<TreatWarningsAsErrors>true</TreatWarningsAsErrors>
|
<TreatWarningsAsErrors>true</TreatWarningsAsErrors>
|
||||||
<SignAssembly>true</SignAssembly>
|
<SignAssembly>true</SignAssembly>
|
||||||
<AssemblyOriginatorKeyFile>../EFCore.NamingConventions.snk</AssemblyOriginatorKeyFile>
|
<AssemblyOriginatorKeyFile>../EFCore.NamingConventions.snk</AssemblyOriginatorKeyFile>
|
||||||
@@ -11,7 +11,7 @@
|
|||||||
<EmbedUntrackedSources>true</EmbedUntrackedSources>
|
<EmbedUntrackedSources>true</EmbedUntrackedSources>
|
||||||
<Description>Naming Conventions for Entity Framework Core Tables and Columns.</Description>
|
<Description>Naming Conventions for Entity Framework Core Tables and Columns.</Description>
|
||||||
<Authors>Shay Rojansky</Authors>
|
<Authors>Shay Rojansky</Authors>
|
||||||
<Copyright>Copyright 2021 © Shay Rojansky</Copyright>
|
<Copyright>Copyright 2022 © Shay Rojansky</Copyright>
|
||||||
<PackageTags>Entity Framework Core;entity-framework-core;ef;efcore;orm;sql</PackageTags>
|
<PackageTags>Entity Framework Core;entity-framework-core;ef;efcore;orm;sql</PackageTags>
|
||||||
<PackageLicenseExpression>Apache-2.0</PackageLicenseExpression>
|
<PackageLicenseExpression>Apache-2.0</PackageLicenseExpression>
|
||||||
<RepositoryType>git</RepositoryType>
|
<RepositoryType>git</RepositoryType>
|
||||||
|
|||||||
@@ -216,32 +216,40 @@ public class NameRewritingConvention :
|
|||||||
{
|
{
|
||||||
foreach (var property in entityType.GetProperties())
|
foreach (var property in entityType.GetProperties())
|
||||||
{
|
{
|
||||||
var columnName = property.GetColumnBaseName();
|
var columnName = property.GetColumnName();
|
||||||
if (columnName.StartsWith(entityType.ShortName() + '_', StringComparison.Ordinal))
|
if (columnName.StartsWith(entityType.ShortName() + '_', StringComparison.Ordinal))
|
||||||
{
|
{
|
||||||
property.Builder.HasColumnName(
|
property.Builder.HasColumnName(
|
||||||
_namingNameRewriter.RewriteName(entityType.ShortName()) + columnName.Substring(entityType.ShortName().Length));
|
_namingNameRewriter.RewriteName(entityType.ShortName()) + columnName.Substring(entityType.ShortName().Length));
|
||||||
}
|
}
|
||||||
|
|
||||||
foreach (var storeObjectType in _storeObjectTypes)
|
var storeObject = StoreObjectIdentifier.Create(entityType, StoreObjectType.Table);
|
||||||
{
|
if (storeObject is null)
|
||||||
var identifier = StoreObjectIdentifier.Create(entityType, storeObjectType);
|
|
||||||
if (identifier is null)
|
|
||||||
{
|
{
|
||||||
continue;
|
continue;
|
||||||
}
|
}
|
||||||
|
|
||||||
if (property.GetColumnNameConfigurationSource(identifier.Value) != ConfigurationSource.Convention)
|
var shortName = entityType.ShortName();
|
||||||
{
|
|
||||||
continue;
|
|
||||||
}
|
|
||||||
|
|
||||||
columnName = property.GetColumnName(identifier.Value);
|
if (property.Builder.CanSetColumnName(null))
|
||||||
if (columnName.StartsWith(entityType.ShortName() + '_', StringComparison.Ordinal))
|
{
|
||||||
|
columnName = property.GetColumnName();
|
||||||
|
if (columnName.StartsWith(shortName + '_', StringComparison.Ordinal))
|
||||||
{
|
{
|
||||||
property.Builder.HasColumnName(
|
property.Builder.HasColumnName(
|
||||||
_namingNameRewriter.RewriteName(entityType.ShortName())
|
_namingNameRewriter.RewriteName(shortName)
|
||||||
+ columnName.Substring(entityType.ShortName().Length));
|
+ columnName.Substring(shortName.Length));
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
if (property.Builder.CanSetColumnName(null, storeObject.Value))
|
||||||
|
{
|
||||||
|
columnName = property.GetColumnName(storeObject.Value);
|
||||||
|
if (columnName is not null && columnName.StartsWith(shortName + '_', StringComparison.Ordinal))
|
||||||
|
{
|
||||||
|
property.Builder.HasColumnName(
|
||||||
|
_namingNameRewriter.RewriteName(shortName) + columnName.Substring(shortName.Length),
|
||||||
|
storeObject.Value);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
@@ -260,7 +268,7 @@ public class NameRewritingConvention :
|
|||||||
// but https://github.com/dotnet/efcore/pull/23834
|
// but https://github.com/dotnet/efcore/pull/23834
|
||||||
var baseColumnName = StoreObjectIdentifier.Create(property.DeclaringEntityType, StoreObjectType.Table) is { } tableIdentifier
|
var baseColumnName = StoreObjectIdentifier.Create(property.DeclaringEntityType, StoreObjectType.Table) is { } tableIdentifier
|
||||||
? property.GetDefaultColumnName(tableIdentifier)
|
? property.GetDefaultColumnName(tableIdentifier)
|
||||||
: property.GetDefaultColumnBaseName();
|
: property.GetDefaultColumnName();
|
||||||
propertyBuilder.HasColumnName(_namingNameRewriter.RewriteName(baseColumnName));
|
propertyBuilder.HasColumnName(_namingNameRewriter.RewriteName(baseColumnName));
|
||||||
|
|
||||||
foreach (var storeObjectType in _storeObjectTypes)
|
foreach (var storeObjectType in _storeObjectTypes)
|
||||||
|
|||||||
@@ -1,7 +1,7 @@
|
|||||||
{
|
{
|
||||||
"sdk": {
|
"sdk": {
|
||||||
"version": "6.0.100-rc.1.21463.6",
|
"version": "7.0.100-rc.2.22477.23",
|
||||||
"rollForward": "latestMajor",
|
"rollForward": "latestMajor",
|
||||||
"allowPrerelease": "true"
|
"allowPrerelease": true
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|||||||
Reference in New Issue
Block a user