Browse Source

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

pull/822/head
Kévin Chalet 6 years ago
parent
commit
874dd44170
  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. 8
      src/OpenIddict.EntityFrameworkCore/Stores/OpenIddictAuthorizationStore.cs
  5. 16
      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(

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

@ -848,7 +848,13 @@ 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.AsQueryable()
.FirstOrDefaultAsync(element => element.Id.Equals(key), cancellationToken);
if (application == null)
{
throw new InvalidOperationException("The application associated with the authorization cannot be found.");

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

@ -909,7 +909,13 @@ 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.AsQueryable()
.FirstOrDefaultAsync(element => element.Id.Equals(key), cancellationToken);
if (application == null)
{
throw new InvalidOperationException("The application associated with the token cannot be found.");
@ -955,7 +961,13 @@ 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.AsQueryable()
.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