-
Notifications
You must be signed in to change notification settings - Fork 3.2k
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Temporal table support for owned and table splitting scenarios
Fix to #26858 - Query: improve TableExpressionBase extensibility by adding annotations Fix to #26469 - Query: enable temporal tables for table splitting scenarios Fix to #26451 - Temporal Table: Owned Entities support? Added annotation infra for TableExpressionBase and annotations for temporal table information. Removed (now unnecessary) temporal specific table expressions. Also added temporal table support for owned typed and table splitting in general using the annotations to store the temporal information (no need for provider specific logic in places where we didn't have good extensibility) For table splitting, every entity must explicitly define period start/end columns. They all need to be the same, but if not explicitly provided we try to uniquefy them. We should fix this so that you only need to specify it in one place but it's currently hard to do (hopefully convention layering will make it easier) Fixes #26858 Fixes #26469 Fixes #26451
- Loading branch information
Showing
60 changed files
with
7,684 additions
and
624 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
79 changes: 79 additions & 0 deletions
79
src/EFCore.Relational/Metadata/Builders/OwnedNavigationTableBuilder.cs
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,79 @@ | ||
// Licensed to the .NET Foundation under one or more agreements. | ||
// The .NET Foundation licenses this file to you under the MIT license. | ||
|
||
using System.ComponentModel; | ||
|
||
namespace Microsoft.EntityFrameworkCore.Metadata.Builders; | ||
|
||
/// <summary> | ||
/// Instances of this class are returned from methods when using the <see cref="ModelBuilder" /> API | ||
/// and it is not designed to be directly constructed in your application code. | ||
/// </summary> | ||
public class OwnedNavigationTableBuilder | ||
{ | ||
/// <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> | ||
[EntityFrameworkInternal] | ||
public OwnedNavigationTableBuilder(OwnedNavigationBuilder ownedNavigationBuilder) | ||
{ | ||
OwnedNavigationBuilder = ownedNavigationBuilder; | ||
} | ||
|
||
/// <summary> | ||
/// The entity type being configured. | ||
/// </summary> | ||
public virtual IMutableEntityType Metadata => OwnedNavigationBuilder.OwnedEntityType; | ||
|
||
/// <summary> | ||
/// The entity type builder. | ||
/// </summary> | ||
public virtual OwnedNavigationBuilder OwnedNavigationBuilder { get; } | ||
|
||
/// <summary> | ||
/// Configures the table to be ignored by migrations. | ||
/// </summary> | ||
/// <remarks> | ||
/// See <see href="https://aka.ms/efcore-docs-migrations">Database migrations</see> for more information. | ||
/// </remarks> | ||
/// <param name="excluded">A value indicating whether the table should be managed by migrations.</param> | ||
/// <returns>The same builder instance so that multiple calls can be chained.</returns> | ||
public virtual OwnedNavigationTableBuilder ExcludeFromMigrations(bool excluded = true) | ||
{ | ||
Metadata.SetIsTableExcludedFromMigrations(excluded); | ||
|
||
return this; | ||
} | ||
|
||
#region Hidden System.Object members | ||
|
||
/// <summary> | ||
/// Returns a string that represents the current object. | ||
/// </summary> | ||
/// <returns>A string that represents the current object.</returns> | ||
[EditorBrowsable(EditorBrowsableState.Never)] | ||
public override string? ToString() | ||
=> base.ToString(); | ||
|
||
/// <summary> | ||
/// Determines whether the specified object is equal to the current object. | ||
/// </summary> | ||
/// <param name="obj">The object to compare with the current object.</param> | ||
/// <returns><see langword="true" /> if the specified object is equal to the current object; otherwise, <see langword="false" />.</returns> | ||
[EditorBrowsable(EditorBrowsableState.Never)] | ||
public override bool Equals(object? obj) | ||
=> base.Equals(obj); | ||
|
||
/// <summary> | ||
/// Serves as the default hash function. | ||
/// </summary> | ||
/// <returns>A hash code for the current object.</returns> | ||
[EditorBrowsable(EditorBrowsableState.Never)] | ||
public override int GetHashCode() | ||
=> base.GetHashCode(); | ||
|
||
#endregion | ||
} |
36 changes: 36 additions & 0 deletions
36
src/EFCore.Relational/Metadata/Builders/OwnedNavigationTableBuilder`.cs
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
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.Builders; | ||
|
||
/// <summary> | ||
/// Instances of this class are returned from methods when using the <see cref="ModelBuilder" /> API | ||
/// and it is not designed to be directly constructed in your application code. | ||
/// </summary> | ||
/// <typeparam name="TEntity">The entity type being configured.</typeparam> | ||
public class OwnedNavigationTableBuilder<TEntity> : OwnedNavigationTableBuilder | ||
where TEntity : class | ||
{ | ||
/// <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> | ||
[EntityFrameworkInternal] | ||
public OwnedNavigationTableBuilder(OwnedNavigationBuilder referenceOwnershipBuilder) | ||
: base(referenceOwnershipBuilder) | ||
{ | ||
} | ||
|
||
/// <summary> | ||
/// Configures the table to be ignored by migrations. | ||
/// </summary> | ||
/// <remarks> | ||
/// See <see href="https://aka.ms/efcore-docs-migrations">Database migrations</see> for more information. | ||
/// </remarks> | ||
/// <param name="excluded">A value indicating whether the table should be managed by migrations.</param> | ||
/// <returns>The same builder instance so that multiple calls can be chained.</returns> | ||
public new virtual OwnedNavigationTableBuilder<TEntity> ExcludeFromMigrations(bool excluded = true) | ||
=> (OwnedNavigationTableBuilder<TEntity>)base.ExcludeFromMigrations(excluded); | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Oops, something went wrong.