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

Revert HasKey binary breaking change and add a test for IdentityServer4 #20620

Merged
merged 1 commit into from
Apr 14, 2020
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.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
3 changes: 2 additions & 1 deletion eng/Versions.props
Original file line number Diff line number Diff line change
Expand Up @@ -28,7 +28,8 @@
<SQLitePCLRawBundleESqlite3PackageVersion>2.0.2</SQLitePCLRawBundleESqlite3PackageVersion>
<SQLitePCLRawBundleESqlcipherPackageVersion>2.0.2</SQLitePCLRawBundleESqlcipherPackageVersion>
<SQLitePCLRawBundleWinsqlite3PackageVersion>2.0.2</SQLitePCLRawBundleWinsqlite3PackageVersion>
<SQLitePCLRawCorePackageVersion>2.0.2</SQLitePCLRawCorePackageVersion>
<SQLitePCLRawCorePackageVersion>2.0.2</SQLitePCLRawCorePackageVersion>
<IdentityServer4EntityFrameworkPackageVersion>3.0.0</IdentityServer4EntityFrameworkPackageVersion>
<StyleCopAnalyzersPackageVersion>1.1.118</StyleCopAnalyzersPackageVersion>
<BenchmarkDotNetPackageVersion>0.12.0</BenchmarkDotNetPackageVersion>
<MicrosoftDataSqlClientPackageVersion>2.0.0-preview1.20021.1</MicrosoftDataSqlClientPackageVersion>
Expand Down
2 changes: 1 addition & 1 deletion src/EFCore/Metadata/Builders/EntityTypeBuilder`.cs
Original file line number Diff line number Diff line change
Expand Up @@ -85,7 +85,7 @@ public virtual EntityTypeBuilder<TEntity> HasBaseType<TBaseType>()
/// </para>
/// </param>
/// <returns> An object that can be used to configure the primary key. </returns>
public virtual KeyBuilder<TEntity> HasKey([NotNull] Expression<Func<TEntity, object>> keyExpression)
public virtual KeyBuilder HasKey([NotNull] Expression<Func<TEntity, object>> keyExpression)
=> new KeyBuilder<TEntity>(
Builder.PrimaryKey(
Check.NotNull(keyExpression, nameof(keyExpression)).GetPropertyAccessList(),
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -30,8 +30,8 @@
</ItemGroup>

<ItemGroup>
<PackageReference Include="IdentityServer4.EntityFramework" Version="$(IdentityServer4EntityFrameworkPackageVersion)" />
<PackageReference Include="Microsoft.Extensions.Configuration.EnvironmentVariables" Version="$(MicrosoftExtensionsConfigurationEnvironmentVariablesPackageVersion)" />
<PackageReference Include="Microsoft.Extensions.Configuration.Json" Version="$(MicrosoftExtensionsConfigurationJsonPackageVersion)" />
</ItemGroup>

</Project>
36 changes: 36 additions & 0 deletions test/EFCore.SqlServer.FunctionalTests/IdentityServerTest.cs
Original file line number Diff line number Diff line change
@@ -0,0 +1,36 @@
// 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 IdentityServer4.EntityFramework.DbContexts;
using IdentityServer4.EntityFramework.Options;
using Microsoft.EntityFrameworkCore.Diagnostics;
using Microsoft.EntityFrameworkCore.TestUtilities;
using Xunit;

namespace Microsoft.EntityFrameworkCore
{
public class IdentityServerTest
{
[ConditionalFact]
public void Can_initialize_PersistedGrantDbContext()
{
using var testDatabase = SqlServerTestStore.CreateInitialized("IdentityServerPersistedGrantDbContext");
var options = CreateOptions(testDatabase);
using (var context = new PersistedGrantDbContext(options, new OperationalStoreOptions()))
{
context.Database.EnsureCreatedResiliently();
}
}

private DbContextOptions<PersistedGrantDbContext> CreateOptions(TestStore testStore)
=> (DbContextOptions<PersistedGrantDbContext>)testStore
.AddProviderOptions(new DbContextOptionsBuilder(new DbContextOptions<PersistedGrantDbContext>()))
.EnableDetailedErrors()
.EnableSensitiveDataLogging()
.ConfigureWarnings(
b => b.Default(WarningBehavior.Throw)
.Log(CoreEventId.SensitiveDataLoggingEnabledWarning)
.Log(CoreEventId.PossibleUnintendedReferenceComparisonWarning))
.Options;
}
}
2 changes: 1 addition & 1 deletion test/EFCore.Tests/ModelBuilding/ModelBuilderGenericTest.cs
Original file line number Diff line number Diff line change
Expand Up @@ -182,7 +182,7 @@ public override TestEntityTypeBuilder<TEntity> HasBaseType(string baseEntityType
=> Wrap(EntityTypeBuilder.HasBaseType(baseEntityTypeName));

public override TestKeyBuilder<TEntity> HasKey(Expression<Func<TEntity, object>> keyExpression)
=> new GenericTestKeyBuilder<TEntity>(EntityTypeBuilder.HasKey(keyExpression));
=> new GenericTestKeyBuilder<TEntity>((KeyBuilder<TEntity>)EntityTypeBuilder.HasKey(keyExpression));

public override TestKeyBuilder<TEntity> HasKey(params string[] propertyNames)
=> new GenericTestKeyBuilder<TEntity>(EntityTypeBuilder.HasKey(propertyNames));
Expand Down