-
Notifications
You must be signed in to change notification settings - Fork 3.4k
Add runtime annotation support to model. #23929
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
Merged
Merged
Changes from all commits
Commits
File filter
Filter by extension
Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
There are no files selected for viewing
This file contains hidden or 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 hidden or 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 hidden or 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 hidden or 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 hidden or 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 hidden or 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 hidden or 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 hidden or 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 hidden or 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
59 changes: 59 additions & 0 deletions
59
src/EFCore.Relational/Infrastructure/RelationalModelDependencies.cs
This file contains hidden or 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,59 @@ | ||
| // Copyright (c) .NET Foundation. All rights reserved. | ||
| // Licensed under the Apache License, Version 2.0. See License.txt in the project root for license information. | ||
|
|
||
| using Microsoft.Extensions.DependencyInjection; | ||
|
|
||
| #nullable enable | ||
|
|
||
| namespace Microsoft.EntityFrameworkCore.Infrastructure | ||
| { | ||
| /// <summary> | ||
| /// <para> | ||
| /// The relational model service dependencies. | ||
| /// </para> | ||
| /// <para> | ||
| /// This type is typically used by database providers (and other extensions). It is generally | ||
| /// not used in application code. | ||
| /// </para> | ||
| /// <para> | ||
| /// Do not construct instances of this class directly from either provider or application code as the | ||
| /// constructor signature may change as new dependencies are added. Instead, use this type in | ||
| /// your constructor so that an instance will be created and injected automatically by the | ||
| /// dependency injection container. To create an instance with some dependent services replaced, | ||
| /// first resolve the object from the dependency injection container, then replace selected | ||
| /// services using the 'With...' methods. Do not call the constructor at any point in this process. | ||
| /// </para> | ||
| /// <para> | ||
| /// The service lifetime is <see cref="ServiceLifetime.Singleton" />. This means that each | ||
| /// <see cref="DbContext" /> instance will use its own instance of this service. | ||
| /// The implementation may depend on other services registered with any lifetime. | ||
| /// The implementation does not need to be thread-safe. | ||
| /// </para> | ||
| /// </summary> | ||
| public sealed record RelationalModelDependencies | ||
| { | ||
| /// <summary> | ||
| /// <para> | ||
| /// Creates the relational model service dependencies. | ||
| /// </para> | ||
| /// <para> | ||
| /// Do not call this constructor directly from either provider or application code as it may change | ||
| /// as new dependencies are added. Instead, use this type in your constructor so that an instance | ||
| /// will be created and injected automatically by the dependency injection container. To create | ||
| /// an instance with some dependent services replaced, first resolve the object from the dependency | ||
| /// injection container, then replace selected services using the 'With...' methods. Do not call | ||
| /// the constructor at any point in this process. | ||
| /// </para> | ||
| /// <para> | ||
| /// 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. | ||
| /// </para> | ||
| /// </summary> | ||
| [EntityFrameworkInternal] | ||
| public RelationalModelDependencies() | ||
| { | ||
| } | ||
| } | ||
| } |
31 changes: 31 additions & 0 deletions
31
src/EFCore.Relational/Infrastructure/RelationalModelExtensions.cs
This file contains hidden or 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,31 @@ | ||
| // Copyright (c) .NET Foundation. All rights reserved. | ||
| // Licensed under the Apache License, Version 2.0. See License.txt in the project root for license information. | ||
|
|
||
| using System; | ||
| using System.Runtime.CompilerServices; | ||
| using JetBrains.Annotations; | ||
| using Microsoft.EntityFrameworkCore.Diagnostics; | ||
| using Microsoft.EntityFrameworkCore.Metadata; | ||
|
|
||
| #nullable enable | ||
|
|
||
| namespace Microsoft.EntityFrameworkCore.Infrastructure | ||
| { | ||
| /// <summary> | ||
| /// Relational-specific extension methods for <see cref="IModel" />. | ||
| /// </summary> | ||
| public static class RelationalModelExtensions | ||
| { | ||
| /// <summary> | ||
| /// Returns the relational service dependencies. | ||
| /// </summary> | ||
| /// <param name="model"> The model. </param> | ||
| /// <param name="methodName"> The name of the calling method. </param> | ||
| /// <returns> The relational service dependencies. </returns> | ||
| public static RelationalModelDependencies GetRelationalDependencies( | ||
| [NotNull] this IModel model, [CallerMemberName][CanBeNull] string methodName = "") | ||
| => (RelationalModelDependencies?)model | ||
| .FindRuntimeAnnotation(RelationalAnnotationNames.ModelDependencies)?.Value | ||
| ?? throw new InvalidOperationException(CoreStrings.ModelNotFinalized(methodName)); | ||
| } | ||
| } |
Oops, something went wrong.
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
Uh oh!
There was an error while loading. Please reload this page.