Browse Source

Add workarounds for API breaking changes introduced in Entity Framework Core 3.x

pull/2236/head
Kévin Chalet 7 years ago
parent
commit
51ea4c4c8b
  1. 5
      src/OpenIddict.EntityFrameworkCore/Configurations/OpenIddictApplicationConfiguration.cs
  2. 5
      src/OpenIddict.EntityFrameworkCore/Configurations/OpenIddictScopeConfiguration.cs
  3. 5
      src/OpenIddict.EntityFrameworkCore/Configurations/OpenIddictTokenConfiguration.cs
  4. 6
      src/OpenIddict.EntityFrameworkCore/Stores/OpenIddictAuthorizationStore.cs
  5. 12
      src/OpenIddict.EntityFrameworkCore/Stores/OpenIddictTokenStore.cs

5
src/OpenIddict.EntityFrameworkCore/Configurations/OpenIddictApplicationConfiguration.cs

@ -40,7 +40,10 @@ namespace OpenIddict.EntityFrameworkCore
builder.HasKey(application => application.Id);
builder.HasIndex(application => application.ClientId)
// Warning: the non-generic overlord is deliberately used to work around
// a breaking change introduced in Entity Framework Core 3.x (where a
// generic entity type builder is now returned by the HasIndex() method).
builder.HasIndex(nameof(OpenIddictApplication.ClientId))
.IsUnique();
builder.Property(application => application.ClientId)

5
src/OpenIddict.EntityFrameworkCore/Configurations/OpenIddictScopeConfiguration.cs

@ -36,7 +36,10 @@ namespace OpenIddict.EntityFrameworkCore
builder.HasKey(scope => scope.Id);
builder.HasIndex(scope => scope.Name)
// Warning: the non-generic overlord is deliberately used to work around
// a breaking change introduced in Entity Framework Core 3.x (where a
// generic entity type builder is now returned by the HasIndex() method).
builder.HasIndex(nameof(OpenIddictScope.Name))
.IsUnique();
builder.Property(scope => scope.ConcurrencyToken)

5
src/OpenIddict.EntityFrameworkCore/Configurations/OpenIddictTokenConfiguration.cs

@ -40,7 +40,10 @@ namespace OpenIddict.EntityFrameworkCore
builder.HasKey(token => token.Id);
builder.HasIndex(token => token.ReferenceId)
// Warning: the non-generic overlord is deliberately used to work around
// a breaking change introduced in Entity Framework Core 3.x (where a
// generic entity type builder is now returned by the HasIndex() method).
builder.HasIndex(nameof(OpenIddictToken.ReferenceId))
.IsUnique();
builder.HasIndex(

6
src/OpenIddict.EntityFrameworkCore/Stores/OpenIddictAuthorizationStore.cs

@ -913,7 +913,11 @@ namespace OpenIddict.EntityFrameworkCore
if (!string.IsNullOrEmpty(identifier))
{
var application = await Applications.FindAsync(new object[] { ConvertIdentifierFromString(identifier) }, cancellationToken);
var key = ConvertIdentifierFromString(identifier);
// Warning: FindAsync() is deliberately not used to work around a breaking change introduced
// in Entity Framework Core 3.x (where a ValueTask instead of a Task is now returned).
var application = await Applications.FirstOrDefaultAsync(element => element.Id.Equals(key), cancellationToken);
if (application == null)
{
throw new InvalidOperationException("The application associated with the authorization cannot be found.");

12
src/OpenIddict.EntityFrameworkCore/Stores/OpenIddictTokenStore.cs

@ -948,7 +948,11 @@ namespace OpenIddict.EntityFrameworkCore
if (!string.IsNullOrEmpty(identifier))
{
var application = await Applications.FindAsync(new object[] { ConvertIdentifierFromString(identifier) }, cancellationToken);
var key = ConvertIdentifierFromString(identifier);
// Warning: FindAsync() is deliberately not used to work around a breaking change introduced
// in Entity Framework Core 3.x (where a ValueTask instead of a Task is now returned).
var application = await Applications.FirstOrDefaultAsync(element => element.Id.Equals(key), cancellationToken);
if (application == null)
{
throw new InvalidOperationException("The application associated with the token cannot be found.");
@ -994,7 +998,11 @@ namespace OpenIddict.EntityFrameworkCore
if (!string.IsNullOrEmpty(identifier))
{
var authorization = await Authorizations.FindAsync(new object[] { ConvertIdentifierFromString(identifier) }, cancellationToken);
var key = ConvertIdentifierFromString(identifier);
// Warning: FindAsync() is deliberately not used to work around a breaking change introduced
// in Entity Framework Core 3.x (where a ValueTask instead of a Task is now returned).
var authorization = await Authorizations.FirstOrDefaultAsync(element => element.Id.Equals(key), cancellationToken);
if (authorization == null)
{
throw new InvalidOperationException("The authorization associated with the token cannot be found.");

Loading…
Cancel
Save