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 TPC support for data seeding #27903

Merged
merged 3 commits into from
Apr 29, 2022
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.
Jump to
Jump to file
Failed to load files.
Diff view
Diff view
Original file line number Diff line number Diff line change
Expand Up @@ -442,7 +442,7 @@ public override void Generate(IProperty property, CSharpRuntimeAnnotationCodeGen
mainBuilder
.Append("var ").Append(overrideVariable).AppendLine(" = new RuntimeRelationalPropertyOverrides(").IncrementIndent()
.Append(parameters.TargetName).AppendLine(",")
.Append(code.Literal(overrides.ColumnNameOverriden)).AppendLine(",")
.Append(code.Literal(overrides.ColumnNameOverridden)).AppendLine(",")
.Append(code.UnknownLiteral(overrides.ColumnName)).AppendLine(");").DecrementIndent();

CreateAnnotations(
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -33,7 +33,7 @@ public static string GetColumnBaseName(this IReadOnlyProperty property)
public static string? GetColumnName(this IReadOnlyProperty property, in StoreObjectIdentifier storeObject)
{
var overrides = RelationalPropertyOverrides.Find(property, storeObject);
if (overrides?.ColumnNameOverriden == true)
if (overrides?.ColumnNameOverridden == true)
{
return overrides.ColumnName;
}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -47,6 +47,7 @@ public class EntityFrameworkRelationalServicesBuilder : EntityFrameworkServicesB
{ typeof(IRowKeyValueFactoryFactory), new ServiceCharacteristics(ServiceLifetime.Singleton) },
{ typeof(IRowForeignKeyValueFactoryFactory), new ServiceCharacteristics(ServiceLifetime.Singleton) },
{ typeof(IRowIndexValueFactoryFactory), new ServiceCharacteristics(ServiceLifetime.Singleton) },
{ typeof(IRowIdentityMapFactory), new ServiceCharacteristics(ServiceLifetime.Singleton) },
{ typeof(IParameterNameGeneratorFactory), new ServiceCharacteristics(ServiceLifetime.Singleton) },
{ typeof(IComparer<IReadOnlyModificationCommand>), new ServiceCharacteristics(ServiceLifetime.Singleton) },
{ typeof(IMigrationsIdGenerator), new ServiceCharacteristics(ServiceLifetime.Singleton) },
Expand Down Expand Up @@ -130,6 +131,7 @@ public override EntityFrameworkServicesBuilder TryAddCoreServices()
TryAdd<IRowKeyValueFactoryFactory, RowKeyValueFactoryFactory>();
TryAdd<IRowForeignKeyValueFactoryFactory, RowForeignKeyValueFactoryFactory>();
TryAdd<IRowIndexValueFactoryFactory, RowIndexValueFactoryFactory>();
TryAdd<IRowIdentityMapFactory, RowIdentityMapFactory>();
TryAdd<IModelCustomizer, RelationalModelCustomizer>();
TryAdd<IModelRuntimeInitializer, RelationalModelRuntimeInitializer>();
TryAdd<IRelationalAnnotationProvider, RelationalAnnotationProvider>();
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -307,7 +307,7 @@ private static RuntimeSequence Create(ISequence sequence, RuntimeModel runtimeMo
RuntimeProperty runtimeProperty)
=> new(
runtimeProperty,
propertyOverrides.ColumnNameOverriden,
propertyOverrides.ColumnNameOverridden,
propertyOverrides.ColumnName);

/// <summary>
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -33,5 +33,5 @@ public interface IRelationalPropertyOverrides : IAnnotatable
/// any release. You should only use it directly in your code with extreme caution and knowing that
/// doing so can result in application failures when updating to a new Entity Framework Core release.
/// </summary>
bool ColumnNameOverriden { get; }
bool ColumnNameOverridden { get; }
}
Original file line number Diff line number Diff line change
Expand Up @@ -77,7 +77,7 @@ public override bool IsReadOnly
/// any release. You should only use it directly in your code with extreme caution and knowing that
/// doing so can result in application failures when updating to a new Entity Framework Core release.
/// </summary>
public virtual bool ColumnNameOverriden
public virtual bool ColumnNameOverridden
=> _columnNameConfigurationSource != null;

/// <summary>
Expand Down
Original file line number Diff line number Diff line change
@@ -0,0 +1,36 @@
// Licensed to the .NET Foundation under one or more agreements.
// The .NET Foundation licenses this file to you under the MIT license.

namespace Microsoft.EntityFrameworkCore.Metadata.Internal;

/// <summary>
/// This is an internal API that supports the Entity Framework Core infrastructure and not subject to
/// the same compatibility standards as public APIs. It may be changed or removed without notice in
/// any release. You should only use it directly in your code with extreme caution and knowing that
/// doing so can result in application failures when updating to a new Entity Framework Core release.
/// </summary>
public sealed class TableBaseIdentityComparer : IEqualityComparer<ITableBase>
{
private TableBaseIdentityComparer()
{
}

/// <summary>
/// This is an internal API that supports the Entity Framework Core infrastructure and not subject to
/// the same compatibility standards as public APIs. It may be changed or removed without notice in
/// any release. You should only use it directly in your code with extreme caution and knowing that
/// doing so can result in application failures when updating to a new Entity Framework Core release.
/// </summary>
public static readonly TableBaseIdentityComparer Instance = new();

/// <inheritdoc />
public bool Equals(ITableBase? x, ITableBase? y)
=> ReferenceEquals(x, y)
|| (x is null
? y is null
: y is not null && x.Name == y.Name && x.Schema == y.Schema);

/// <inheritdoc />
public int GetHashCode(ITableBase obj)
=> HashCode.Combine(obj.Name, obj.Schema);
}
Original file line number Diff line number Diff line change
Expand Up @@ -17,15 +17,15 @@ public class RuntimeRelationalPropertyOverrides : AnnotatableBase, IRelationalPr
/// Initializes a new instance of the <see cref="RuntimeRelationalPropertyOverrides" /> class.
/// </summary>
/// <param name="property">The property for which the overrides are applied.</param>
/// <param name="columnNameOverriden">Whether the column name is overridden.</param>
/// <param name="columnNameOverridden">Whether the column name is overridden.</param>
/// <param name="columnName">The column name.</param>
public RuntimeRelationalPropertyOverrides(
RuntimeProperty property,
bool columnNameOverriden,
bool columnNameOverridden,
string? columnName)
{
Property = property;
if (columnNameOverriden)
if (columnNameOverridden)
{
SetAnnotation(RelationalAnnotationNames.ColumnName, columnName);
}
Expand All @@ -51,7 +51,7 @@ IProperty IRelationalPropertyOverrides.Property
}

/// <inheritdoc />
bool IRelationalPropertyOverrides.ColumnNameOverriden
bool IRelationalPropertyOverrides.ColumnNameOverridden
{
[DebuggerStepThrough]
get => FindAnnotation(RelationalAnnotationNames.ColumnName) != null;
Expand Down