Skip to content

Commit

Permalink
Revert HasKey binary breaking change and add a test for IdentityServer4
Browse files Browse the repository at this point in the history
  • Loading branch information
AndriySvyryd committed Apr 14, 2020
1 parent a8bc2b6 commit 7a30fe7
Show file tree
Hide file tree
Showing 5 changed files with 41 additions and 4 deletions.
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

0 comments on commit 7a30fe7

Please sign in to comment.