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

[automated] Merge branch 'release/9.0' => 'main' #34719

Merged
merged 7 commits into from
Sep 23, 2024
2 changes: 2 additions & 0 deletions Directory.Packages.props
Original file line number Diff line number Diff line change
Expand Up @@ -7,6 +7,8 @@
<ManagePackageVersionsCentrally>true</ManagePackageVersionsCentrally>
<CentralPackageTransitivePinningEnabled>true</CentralPackageTransitivePinningEnabled>
<CentralPackageVersionOverrideEnabled>true</CentralPackageVersionOverrideEnabled>
<!-- Do not warn for missing source mappings -->
<NoWarn>$(NoWarn);NU1507</NoWarn>
</PropertyGroup>
<ItemGroup>
<!-- core dependencies-->
Expand Down
32 changes: 0 additions & 32 deletions NuGet.config
Original file line number Diff line number Diff line change
Expand Up @@ -18,38 +18,6 @@
<!-- Used for the Rich Navigation indexing task -->
<add key="richnav" value="https://pkgs.dev.azure.com/azure-public/vside/_packaging/vs-buildservices/nuget/v3/index.json" />
</packageSources>
<packageSourceMapping>
<packageSource key="dotnet10-transport">
<package pattern="*" />
</packageSource>
<packageSource key="dotnet10">
<package pattern="*" />
</packageSource>
<packageSource key="dotnet9-transport">
<package pattern="*" />
</packageSource>
<packageSource key="dotnet9">
<package pattern="*" />
</packageSource>
<packageSource key="dotnet-public">
<package pattern="*" />
</packageSource>
<packageSource key="dotnet-eng">
<package pattern="*" />
</packageSource>
<packageSource key="dotnet-tools">
<package pattern="*" />
</packageSource>
<packageSource key="dotnet8-transport">
<package pattern="*" />
</packageSource>
<packageSource key="dotnet8">
<package pattern="*" />
</packageSource>
<packageSource key="richnav">
<package pattern="*" />
</packageSource>
</packageSourceMapping>
Comment on lines -21 to -52

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

<auditSources>
<clear />
<add key="nuget.org" value="https://api.nuget.org/v3/index.json" />
Expand Down
2 changes: 1 addition & 1 deletion src/EFCore.Analyzers/EFCore.Analyzers.csproj
Original file line number Diff line number Diff line change
Expand Up @@ -10,7 +10,7 @@
<CodeAnalysisRuleSet>$(MSBuildThisFileDirectory)..\..\rulesets\EFCore.noxmldocs.ruleset</CodeAnalysisRuleSet>
<ImplicitUsings>true</ImplicitUsings>
<EnforceExtendedAnalyzerRules>true</EnforceExtendedAnalyzerRules>
<NoWarn>NU5128</NoWarn>
<NoWarn>$(NoWarn);NU5128</NoWarn>
</PropertyGroup>

<ItemGroup>
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -531,7 +531,7 @@ public static EntityTypeBuilder HasDiscriminatorInJsonId(
/// <see langword="null" /> to revert to the default setting.
/// </param>
/// <returns>The same builder instance so that multiple calls can be chained.</returns>
public static EntityTypeBuilder IncludeRootDiscriminatorInJsonId(
public static EntityTypeBuilder HasRootDiscriminatorInJsonId(
this EntityTypeBuilder entityTypeBuilder,
bool? includeDiscriminator = true)
{
Expand Down Expand Up @@ -578,11 +578,11 @@ public static EntityTypeBuilder<TEntity> HasDiscriminatorInJsonId<TEntity>(
/// <see langword="null" /> to revert to the default setting.
/// </param>
/// <returns>The same builder instance so that multiple calls can be chained.</returns>
public static EntityTypeBuilder<TEntity> IncludeRootDiscriminatorInJsonId<TEntity>(
public static EntityTypeBuilder<TEntity> HasRootDiscriminatorInJsonId<TEntity>(
this EntityTypeBuilder<TEntity> entityTypeBuilder,
bool? includeDiscriminator = true)
where TEntity : class
=> (EntityTypeBuilder<TEntity>)IncludeRootDiscriminatorInJsonId((EntityTypeBuilder)entityTypeBuilder, includeDiscriminator);
=> (EntityTypeBuilder<TEntity>)HasRootDiscriminatorInJsonId((EntityTypeBuilder)entityTypeBuilder, includeDiscriminator);

/// <summary>
/// Includes the discriminator value of the entity type in the JSON "id" value. This was the default behavior before EF Core 9.
Expand Down Expand Up @@ -633,12 +633,12 @@ public static EntityTypeBuilder<TEntity> IncludeRootDiscriminatorInJsonId<TEntit
/// </param>
/// <param name="fromDataAnnotation">Indicates whether the configuration was specified using a data annotation.</param>
/// <returns>The same builder instance if the configuration was applied, <see langword="null" /> otherwise.</returns>
public static IConventionEntityTypeBuilder? IncludeRootDiscriminatorInJsonId(
public static IConventionEntityTypeBuilder? HasRootDiscriminatorInJsonId(
this IConventionEntityTypeBuilder entityTypeBuilder,
bool? includeDiscriminator,
bool fromDataAnnotation = false)
{
if (!entityTypeBuilder.CanSetIncludeRootDiscriminatorInJsonId(includeDiscriminator, fromDataAnnotation))
if (!entityTypeBuilder.CanSetRootDiscriminatorInJsonId(includeDiscriminator, fromDataAnnotation))
{
return null;
}
Expand Down Expand Up @@ -699,7 +699,7 @@ public static bool CanSetDiscriminatorInJsonId(
/// </param>
/// <param name="fromDataAnnotation">Indicates whether the configuration was specified using a data annotation.</param>
/// <returns><see langword="true" /> if the configuration can be applied.</returns>
public static bool CanSetIncludeRootDiscriminatorInJsonId(
public static bool CanSetRootDiscriminatorInJsonId(
this IConventionEntityTypeBuilder entityTypeBuilder,
bool? includeDiscriminator,
bool fromDataAnnotation = false)
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -165,7 +165,7 @@ public static ModelBuilder HasDiscriminatorInJsonIds(
/// <see langword="null" /> to revert to the default setting.
/// </param>
/// <returns>The same builder instance so that multiple calls can be chained.</returns>
public static ModelBuilder IncludeRootDiscriminatorInJsonId(
public static ModelBuilder HasRootDiscriminatorInJsonId(
this ModelBuilder modelBuilder,
bool? includeDiscriminator = true)
{
Expand Down
2 changes: 1 addition & 1 deletion src/EFCore.Design/EFCore.Design.csproj
Original file line number Diff line number Diff line change
Expand Up @@ -8,7 +8,7 @@
<GenerateDocumentationFile>true</GenerateDocumentationFile>
<DevelopmentDependency>true</DevelopmentDependency>
<ImplicitUsings>true</ImplicitUsings>
<NoWarn>EF9100</NoWarn> <!-- Precompiled query is experimental -->
<NoWarn>$(NoWarn);EF9100</NoWarn> <!-- Precompiled query is experimental -->
</PropertyGroup>

<ItemGroup>
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -2068,7 +2068,7 @@ IEnumerable<IView> IRelationalModel.Views
IEnumerable<IStoreFunction> IRelationalModel.Functions
{
[DebuggerStepThrough]
get => Functions.OrderBy(f => f.Key).Select(t => t.Value);
get => Functions.OrderBy(f => f.Key, NamedListComparer.Instance).Select(t => t.Value);
}

IEnumerable<IStoreStoredProcedure> IRelationalModel.StoredProcedures
Expand Down
2 changes: 1 addition & 1 deletion src/EFCore.SqlServer/EFCore.SqlServer.csproj
Original file line number Diff line number Diff line change
Expand Up @@ -9,7 +9,7 @@
<GenerateDocumentationFile>true</GenerateDocumentationFile>
<PackageTags>$(PackageTags);SQL Server</PackageTags>
<ImplicitUsings>true</ImplicitUsings>
<NoWarn>EF9100</NoWarn> <!-- Precompiled query is experimental -->
<NoWarn>$(NoWarn);EF9100</NoWarn> <!-- Precompiled query is experimental -->
</PropertyGroup>

<ItemGroup>
Expand Down
2 changes: 1 addition & 1 deletion src/EFCore.Sqlite.Core/EFCore.Sqlite.Core.csproj
Original file line number Diff line number Diff line change
Expand Up @@ -10,7 +10,7 @@
<GenerateDocumentationFile>true</GenerateDocumentationFile>
<PackageTags>$(PackageTags);SQLite</PackageTags>
<ImplicitUsings>true</ImplicitUsings>
<NoWarn>EF9100</NoWarn> <!-- Precompiled query is experimental -->
<NoWarn>$(NoWarn);EF9100</NoWarn> <!-- Precompiled query is experimental -->
</PropertyGroup>

<ItemGroup>
Expand Down
2 changes: 1 addition & 1 deletion src/EFCore.Tasks/EFCore.Tasks.csproj
Original file line number Diff line number Diff line change
Expand Up @@ -10,7 +10,7 @@
<GenerateDependencyFile>true</GenerateDependencyFile>
<SuppressDependenciesWhenPacking>true</SuppressDependenciesWhenPacking>
<DevelopmentDependency>true</DevelopmentDependency>
<NoWarn>NU5100;NU5128</NoWarn>
<NoWarn>$(NoWarn);NU5100;NU5128</NoWarn>
<ImplicitUsings>true</ImplicitUsings>
<CodeAnalysisRuleSet>$(MSBuildThisFileDirectory)..\..\rulesets\EFCore.noxmldocs.ruleset</CodeAnalysisRuleSet>
</PropertyGroup>
Expand Down
6 changes: 3 additions & 3 deletions test/EFCore.Cosmos.FunctionalTests/FindCosmosTest.cs
Original file line number Diff line number Diff line change
Expand Up @@ -461,11 +461,11 @@ protected override void OnModelCreating(ModelBuilder modelBuilder, DbContext con

modelBuilder.Entity<IntKey>()
.ToContainer("Ints")
.IncludeRootDiscriminatorInJsonId();
.HasRootDiscriminatorInJsonId();

modelBuilder.Entity<NullableIntKey>()
.ToContainer("Ints")
.IncludeRootDiscriminatorInJsonId();
.HasRootDiscriminatorInJsonId();

modelBuilder.Entity<StringKey>()
.ToContainer("Strings");
Expand All @@ -475,7 +475,7 @@ protected override void OnModelCreating(ModelBuilder modelBuilder, DbContext con

modelBuilder.Entity<BaseType>()
.ToContainer("Base")
.IncludeRootDiscriminatorInJsonId();
.HasRootDiscriminatorInJsonId();

modelBuilder.Entity<ShadowKey>().ToContainer("ShadowKeys");
}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -20,7 +20,7 @@ protected override void OnModelCreating(ModelBuilder modelBuilder, DbContext con
{
base.OnModelCreating(modelBuilder, context);

modelBuilder.IncludeRootDiscriminatorInJsonId();
modelBuilder.HasRootDiscriminatorInJsonId();
}

public override DbContextOptionsBuilder AddOptions(DbContextOptionsBuilder builder)
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -42,32 +42,32 @@ protected override void OnModelCreating(ModelBuilder modelBuilder, DbContext con
modelBuilder.Entity<Employee>().ToContainer("Employees");

modelBuilder.Entity<Order>()
.IncludeRootDiscriminatorInJsonId()
.HasRootDiscriminatorInJsonId()
.ToContainer("ProductsAndOrders");

modelBuilder.Entity<OrderDetail>()
.IncludeRootDiscriminatorInJsonId()
.HasRootDiscriminatorInJsonId()
.ToContainer("ProductsAndOrders");

modelBuilder.Entity<Product>()
.IncludeRootDiscriminatorInJsonId()
.HasRootDiscriminatorInJsonId()
.ToContainer("ProductsAndOrders");

modelBuilder.Entity<OrderQuery>()
.ToContainer("ProductsAndOrders")
.IncludeRootDiscriminatorInJsonId()
.HasRootDiscriminatorInJsonId()
.HasDiscriminator<string>("$type").HasValue("Order");

modelBuilder
.Entity<ProductQuery>()
.ToContainer("ProductsAndOrders")
.IncludeRootDiscriminatorInJsonId()
.HasRootDiscriminatorInJsonId()
.HasDiscriminator<string>("$type").HasValue("Product");

modelBuilder
.Entity<ProductView>()
.ToContainer("ProductsAndOrders")
.IncludeRootDiscriminatorInJsonId()
.HasRootDiscriminatorInJsonId()
.HasDiscriminator<string>("$type").HasValue("ProductView");

modelBuilder
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -858,7 +858,7 @@ protected override void OnModelCreating(ModelBuilder modelBuilder, DbContext con
{
base.OnModelCreating(modelBuilder, context);

modelBuilder.IncludeRootDiscriminatorInJsonId();
modelBuilder.HasRootDiscriminatorInJsonId();
}
}
}
47 changes: 37 additions & 10 deletions test/EFCore.Relational.Tests/Metadata/RelationalModelTest.cs
Original file line number Diff line number Diff line change
Expand Up @@ -3046,6 +3046,9 @@ public void Can_use_relational_model_with_SQL_queries()
private static IQueryable<Order> GetOrdersForCustomer(int id)
=> throw new NotImplementedException();

private static IQueryable<Order> GetOrdersForCustomer(string name)
=> throw new NotImplementedException();

[ConditionalFact]
public void Can_use_relational_model_with_functions()
{
Expand All @@ -3064,41 +3067,50 @@ public void Can_use_relational_model_with_functions()

modelBuilder.HasDbFunction(
typeof(RelationalModelTest).GetMethod(
nameof(GetOrdersForCustomer), BindingFlags.NonPublic | BindingFlags.Static));
nameof(GetOrdersForCustomer), BindingFlags.NonPublic | BindingFlags.Static, [typeof(int)] ));

modelBuilder.HasDbFunction(
typeof(RelationalModelTest).GetMethod(
nameof(GetOrdersForCustomer), BindingFlags.NonPublic | BindingFlags.Static, [typeof(string)]));

var model = Finalize(modelBuilder);

Assert.Single(model.Model.GetEntityTypes());
Assert.Equal(2, model.Functions.Count());
Assert.Equal(3, model.Functions.Count());
Assert.Empty(model.Views);
Assert.Empty(model.Tables);

var orderType = model.Model.FindEntityType(typeof(Order));
Assert.Null(orderType.FindPrimaryKey());

Assert.Equal(2, orderType.GetFunctionMappings().Count());
Assert.Equal(3, orderType.GetFunctionMappings().Count());
var orderMapping = orderType.GetFunctionMappings().First();
Assert.Null(orderMapping.IsSharedTablePrincipal);
Assert.Null(orderMapping.IsSplitEntityTypePrincipal);
Assert.True(orderMapping.IsDefaultFunctionMapping);

var tvfMapping = orderType.GetFunctionMappings().Last();
var tvfMapping = orderType.GetFunctionMappings().ElementAt(1);
Assert.Null(tvfMapping.IsSharedTablePrincipal);
Assert.Null(tvfMapping.IsSplitEntityTypePrincipal);
Assert.False(tvfMapping.IsDefaultFunctionMapping);

var tvfMapping2 = orderType.GetFunctionMappings().Last();
Assert.Null(tvfMapping2.IsSharedTablePrincipal);
Assert.Null(tvfMapping2.IsSplitEntityTypePrincipal);
Assert.False(tvfMapping2.IsDefaultFunctionMapping);

Assert.Null(orderMapping.IncludesDerivedTypes);
Assert.Equal(
new[] { nameof(Order.AlternateId), nameof(Order.CustomerId), nameof(Order.Id), nameof(Order.OrderDate) },
[nameof(Order.AlternateId), nameof(Order.CustomerId), nameof(Order.Id), nameof(Order.OrderDate)],
orderMapping.ColumnMappings.Select(m => m.Property.Name));

var ordersFunction = orderMapping.StoreFunction;
Assert.Same(ordersFunction, model.FindFunction(ordersFunction.Name, ordersFunction.Schema, []));
Assert.Equal(
new[] { orderType },
[orderType],
ordersFunction.EntityTypeMappings.Select(m => m.TypeBase));
Assert.Equal(
new[] { nameof(Order.CustomerId), nameof(Order.Id), nameof(Order.OrderDate), "SomeName" },
[nameof(Order.CustomerId), nameof(Order.Id), nameof(Order.OrderDate), "SomeName"],
ordersFunction.Columns.Select(m => m.Name));
Assert.Equal("GetOrders", ordersFunction.Name);
Assert.Null(ordersFunction.Schema);
Expand All @@ -3117,7 +3129,7 @@ public void Can_use_relational_model_with_functions()
Assert.Same(orderDateColumn, ordersFunction.FindColumn(nameof(Order.OrderDate)));
Assert.Same(orderDateColumn, orderDate.FindColumn(StoreObjectIdentifier.DbFunction(ordersFunction.Name)));
Assert.Same(orderDateColumn, ordersFunction.FindColumn(orderDate));
Assert.Equal(new[] { orderDate }, orderDateColumn.PropertyMappings.Select(m => m.Property));
Assert.Equal([orderDate], orderDateColumn.PropertyMappings.Select(m => m.Property));
Assert.Equal(nameof(Order.OrderDate), orderDateColumn.Name);
Assert.Equal("default_datetime_mapping", orderDateColumn.StoreType);
Assert.False(orderDateColumn.IsNullable);
Expand All @@ -3127,7 +3139,7 @@ public void Can_use_relational_model_with_functions()

var tvfFunction = tvfMapping.StoreFunction;
Assert.Same(tvfMapping, tvfFunction.EntityTypeMappings.Single());
Assert.Same(tvfFunction, model.FindFunction(tvfFunction.Name, tvfFunction.Schema, new[] { "default_int_mapping" }));
Assert.Same(tvfFunction, model.FindFunction(tvfFunction.Name, tvfFunction.Schema, ["default_int_mapping"]));
Assert.Equal(nameof(GetOrdersForCustomer), tvfFunction.Name);
Assert.Null(tvfFunction.Schema);
Assert.False(tvfFunction.IsBuiltIn);
Expand All @@ -3136,9 +3148,24 @@ public void Can_use_relational_model_with_functions()

var tvfDbFunction = tvfFunction.DbFunctions.Single();
Assert.Same(tvfFunction, tvfDbFunction.StoreFunction);
Assert.Same(model.Model.GetDbFunctions().Single(f => f.Parameters.Count() == 1), tvfDbFunction);
Assert.Same(model.Model.GetDbFunctions().First(f => f.Parameters.Count() == 1), tvfDbFunction);
Assert.Same(tvfFunction.Parameters.Single(), tvfDbFunction.Parameters.Single().StoreFunctionParameter);
Assert.Equal(tvfDbFunction.Parameters.Single().Name, tvfFunction.Parameters.Single().DbFunctionParameters.Single().Name);

var tvfFunction2 = tvfMapping2.StoreFunction;
Assert.Same(tvfMapping2, tvfFunction2.EntityTypeMappings.Single());
Assert.Same(tvfFunction2, model.FindFunction(tvfFunction2.Name, tvfFunction2.Schema, ["just_string(max)"]));
Assert.Equal(nameof(GetOrdersForCustomer), tvfFunction2.Name);
Assert.Null(tvfFunction2.Schema);
Assert.False(tvfFunction2.IsBuiltIn);
Assert.False(tvfFunction2.IsShared);
Assert.Null(tvfFunction2.ReturnType);

var tvfDbFunction2 = tvfFunction2.DbFunctions.Single();
Assert.Same(tvfFunction2, tvfDbFunction2.StoreFunction);
Assert.Same(model.Model.GetDbFunctions().Last(f => f.Parameters.Count() == 1), tvfDbFunction2);
Assert.Same(tvfFunction2.Parameters.Single(), tvfDbFunction2.Parameters.Single().StoreFunctionParameter);
Assert.Equal(tvfDbFunction2.Parameters.Single().Name, tvfFunction2.Parameters.Single().DbFunctionParameters.Single().Name);
}

[ConditionalFact]
Expand Down