12 changed files with 581 additions and 251 deletions
@ -0,0 +1,72 @@ |
|||||
|
/* |
||||
|
* Licensed under the Apache License, Version 2.0 (http://www.apache.org/licenses/LICENSE-2.0)
|
||||
|
* See https://github.com/openiddict/openiddict-core for more information concerning
|
||||
|
* the license and the contributors participating to this project. |
||||
|
*/ |
||||
|
|
||||
|
using System; |
||||
|
using System.ComponentModel; |
||||
|
using System.ComponentModel.DataAnnotations.Schema; |
||||
|
using System.Data.Entity.Infrastructure.Annotations; |
||||
|
using System.Data.Entity.ModelConfiguration; |
||||
|
using System.Text; |
||||
|
using OpenIddict.EntityFramework.Models; |
||||
|
|
||||
|
namespace OpenIddict.EntityFramework |
||||
|
{ |
||||
|
/// <summary>
|
||||
|
/// Defines a relational mapping for the Application entity.
|
||||
|
/// </summary>
|
||||
|
/// <typeparam name="TApplication">The type of the Application entity.</typeparam>
|
||||
|
/// <typeparam name="TAuthorization">The type of the Authorization entity.</typeparam>
|
||||
|
/// <typeparam name="TToken">The type of the Token entity.</typeparam>
|
||||
|
/// <typeparam name="TKey">The type of the Key entity.</typeparam>
|
||||
|
[EditorBrowsable(EditorBrowsableState.Never)] |
||||
|
public class OpenIddictApplicationConfiguration<TApplication, TAuthorization, TToken, TKey> : EntityTypeConfiguration<TApplication> |
||||
|
where TApplication : OpenIddictApplication<TKey, TAuthorization, TToken> |
||||
|
where TAuthorization : OpenIddictAuthorization<TKey, TApplication, TToken> |
||||
|
where TToken : OpenIddictToken<TKey, TApplication, TAuthorization> |
||||
|
where TKey : IEquatable<TKey> |
||||
|
{ |
||||
|
public OpenIddictApplicationConfiguration() |
||||
|
{ |
||||
|
// Note: unlike Entity Framework Core 1.x/2.x, Entity Framework 6.x
|
||||
|
// always throws an exception when using generic types as entity types.
|
||||
|
// To ensure a better exception is thrown, a manual check is made here.
|
||||
|
if (typeof(TApplication).IsGenericType) |
||||
|
{ |
||||
|
throw new InvalidOperationException(new StringBuilder() |
||||
|
.AppendLine("The application entity cannot be a generic type.") |
||||
|
.Append("Consider creating a non-generic derived class.") |
||||
|
.ToString()); |
||||
|
} |
||||
|
|
||||
|
// Warning: optional foreign keys MUST NOT be added as CLR properties because
|
||||
|
// Entity Framework would throw an exception due to the TKey generic parameter
|
||||
|
// being non-nullable when using value types like short, int, long or Guid.
|
||||
|
|
||||
|
HasKey(application => application.Id); |
||||
|
|
||||
|
Property(application => application.ClientId) |
||||
|
.IsRequired() |
||||
|
.HasMaxLength(450) |
||||
|
.HasColumnAnnotation(IndexAnnotation.AnnotationName, new IndexAnnotation(new IndexAttribute())); |
||||
|
|
||||
|
Property(application => application.ConcurrencyToken) |
||||
|
.IsConcurrencyToken(); |
||||
|
|
||||
|
Property(application => application.Type) |
||||
|
.IsRequired(); |
||||
|
|
||||
|
HasMany(application => application.Authorizations) |
||||
|
.WithOptional(authorization => authorization.Application) |
||||
|
.Map(association => association.MapKey("ApplicationId")); |
||||
|
|
||||
|
HasMany(application => application.Tokens) |
||||
|
.WithOptional(token => token.Application) |
||||
|
.Map(association => association.MapKey("ApplicationId")); |
||||
|
|
||||
|
ToTable("OpenIddictApplications"); |
||||
|
} |
||||
|
} |
||||
|
} |
||||
@ -0,0 +1,68 @@ |
|||||
|
/* |
||||
|
* Licensed under the Apache License, Version 2.0 (http://www.apache.org/licenses/LICENSE-2.0)
|
||||
|
* See https://github.com/openiddict/openiddict-core for more information concerning
|
||||
|
* the license and the contributors participating to this project. |
||||
|
*/ |
||||
|
|
||||
|
using System; |
||||
|
using System.ComponentModel; |
||||
|
using System.Data.Entity.ModelConfiguration; |
||||
|
using System.Text; |
||||
|
using OpenIddict.EntityFramework.Models; |
||||
|
|
||||
|
namespace OpenIddict.EntityFramework |
||||
|
{ |
||||
|
/// <summary>
|
||||
|
/// Defines a relational mapping for the Authorization entity.
|
||||
|
/// </summary>
|
||||
|
/// <typeparam name="TAuthorization">The type of the Authorization entity.</typeparam>
|
||||
|
/// <typeparam name="TApplication">The type of the Application entity.</typeparam>
|
||||
|
/// <typeparam name="TToken">The type of the Token entity.</typeparam>
|
||||
|
/// <typeparam name="TKey">The type of the Key entity.</typeparam>
|
||||
|
[EditorBrowsable(EditorBrowsableState.Never)] |
||||
|
public class OpenIddictAuthorizationConfiguration<TAuthorization, TApplication, TToken, TKey> : EntityTypeConfiguration<TAuthorization> |
||||
|
where TAuthorization : OpenIddictAuthorization<TKey, TApplication, TToken> |
||||
|
where TApplication : OpenIddictApplication<TKey, TAuthorization, TToken> |
||||
|
where TToken : OpenIddictToken<TKey, TApplication, TAuthorization> |
||||
|
where TKey : IEquatable<TKey> |
||||
|
{ |
||||
|
public OpenIddictAuthorizationConfiguration() |
||||
|
{ |
||||
|
// Note: unlike Entity Framework Core 1.x/2.x, Entity Framework 6.x
|
||||
|
// always throws an exception when using generic types as entity types.
|
||||
|
// To ensure a better exception is thrown, a manual check is made here.
|
||||
|
if (typeof(TAuthorization).IsGenericType) |
||||
|
{ |
||||
|
throw new InvalidOperationException(new StringBuilder() |
||||
|
.AppendLine("The authorization entity cannot be a generic type.") |
||||
|
.Append("Consider creating a non-generic derived class.") |
||||
|
.ToString()); |
||||
|
} |
||||
|
|
||||
|
// Warning: optional foreign keys MUST NOT be added as CLR properties because
|
||||
|
// Entity Framework would throw an exception due to the TKey generic parameter
|
||||
|
// being non-nullable when using value types like short, int, long or Guid.
|
||||
|
|
||||
|
HasKey(authorization => authorization.Id); |
||||
|
|
||||
|
Property(authorization => authorization.ConcurrencyToken) |
||||
|
.IsConcurrencyToken(); |
||||
|
|
||||
|
Property(authorization => authorization.Status) |
||||
|
.IsRequired(); |
||||
|
|
||||
|
Property(authorization => authorization.Subject) |
||||
|
.IsRequired(); |
||||
|
|
||||
|
Property(authorization => authorization.Type) |
||||
|
.IsRequired(); |
||||
|
|
||||
|
HasMany(authorization => authorization.Tokens) |
||||
|
.WithOptional(token => token.Authorization) |
||||
|
.Map(association => association.MapKey("AuthorizationId")) |
||||
|
.WillCascadeOnDelete(); |
||||
|
|
||||
|
ToTable("OpenIddictAuthorizations"); |
||||
|
} |
||||
|
} |
||||
|
} |
||||
@ -0,0 +1,57 @@ |
|||||
|
/* |
||||
|
* Licensed under the Apache License, Version 2.0 (http://www.apache.org/licenses/LICENSE-2.0)
|
||||
|
* See https://github.com/openiddict/openiddict-core for more information concerning
|
||||
|
* the license and the contributors participating to this project. |
||||
|
*/ |
||||
|
|
||||
|
using System; |
||||
|
using System.ComponentModel; |
||||
|
using System.ComponentModel.DataAnnotations.Schema; |
||||
|
using System.Data.Entity.Infrastructure.Annotations; |
||||
|
using System.Data.Entity.ModelConfiguration; |
||||
|
using System.Text; |
||||
|
using OpenIddict.EntityFramework.Models; |
||||
|
|
||||
|
namespace OpenIddict.EntityFramework |
||||
|
{ |
||||
|
/// <summary>
|
||||
|
/// Defines a relational mapping for the Scope entity.
|
||||
|
/// </summary>
|
||||
|
/// <typeparam name="TScope">The type of the Scope entity.</typeparam>
|
||||
|
/// <typeparam name="TKey">The type of the Key entity.</typeparam>
|
||||
|
[EditorBrowsable(EditorBrowsableState.Never)] |
||||
|
public class OpenIddictScopeConfiguration<TScope, TKey> : EntityTypeConfiguration<TScope> |
||||
|
where TScope : OpenIddictScope<TKey> |
||||
|
where TKey : IEquatable<TKey> |
||||
|
{ |
||||
|
public OpenIddictScopeConfiguration() |
||||
|
{ |
||||
|
// Note: unlike Entity Framework Core 1.x/2.x, Entity Framework 6.x
|
||||
|
// always throws an exception when using generic types as entity types.
|
||||
|
// To ensure a better exception is thrown, a manual check is made here.
|
||||
|
if (typeof(TScope).IsGenericType) |
||||
|
{ |
||||
|
throw new InvalidOperationException(new StringBuilder() |
||||
|
.AppendLine("The scope entity cannot be a generic type.") |
||||
|
.Append("Consider creating a non-generic derived class.") |
||||
|
.ToString()); |
||||
|
} |
||||
|
|
||||
|
// Warning: optional foreign keys MUST NOT be added as CLR properties because
|
||||
|
// Entity Framework would throw an exception due to the TKey generic parameter
|
||||
|
// being non-nullable when using value types like short, int, long or Guid.
|
||||
|
|
||||
|
HasKey(scope => scope.Id); |
||||
|
|
||||
|
Property(scope => scope.ConcurrencyToken) |
||||
|
.IsConcurrencyToken(); |
||||
|
|
||||
|
Property(scope => scope.Name) |
||||
|
.IsRequired() |
||||
|
.HasMaxLength(450) |
||||
|
.HasColumnAnnotation(IndexAnnotation.AnnotationName, new IndexAnnotation(new IndexAttribute())); |
||||
|
|
||||
|
ToTable("OpenIddictScopes"); |
||||
|
} |
||||
|
} |
||||
|
} |
||||
@ -0,0 +1,66 @@ |
|||||
|
/* |
||||
|
* Licensed under the Apache License, Version 2.0 (http://www.apache.org/licenses/LICENSE-2.0)
|
||||
|
* See https://github.com/openiddict/openiddict-core for more information concerning
|
||||
|
* the license and the contributors participating to this project. |
||||
|
*/ |
||||
|
|
||||
|
using System; |
||||
|
using System.ComponentModel; |
||||
|
using System.ComponentModel.DataAnnotations.Schema; |
||||
|
using System.Data.Entity.Infrastructure.Annotations; |
||||
|
using System.Data.Entity.ModelConfiguration; |
||||
|
using System.Text; |
||||
|
using OpenIddict.EntityFramework.Models; |
||||
|
|
||||
|
namespace OpenIddict.EntityFramework |
||||
|
{ |
||||
|
/// <summary>
|
||||
|
/// Defines a relational mapping for the Token entity.
|
||||
|
/// </summary>
|
||||
|
/// <typeparam name="TToken">The type of the Token entity.</typeparam>
|
||||
|
/// <typeparam name="TApplication">The type of the Application entity.</typeparam>
|
||||
|
/// <typeparam name="TAuthorization">The type of the Authorization entity.</typeparam>
|
||||
|
/// <typeparam name="TKey">The type of the Key entity.</typeparam>
|
||||
|
[EditorBrowsable(EditorBrowsableState.Never)] |
||||
|
public class OpenIddictTokenConfiguration<TToken, TApplication, TAuthorization, TKey> : EntityTypeConfiguration<TToken> |
||||
|
where TToken : OpenIddictToken<TKey, TApplication, TAuthorization> |
||||
|
where TApplication : OpenIddictApplication<TKey, TAuthorization, TToken> |
||||
|
where TAuthorization : OpenIddictAuthorization<TKey, TApplication, TToken> |
||||
|
where TKey : IEquatable<TKey> |
||||
|
{ |
||||
|
public OpenIddictTokenConfiguration() |
||||
|
{ |
||||
|
// Note: unlike Entity Framework Core 1.x/2.x, Entity Framework 6.x
|
||||
|
// always throws an exception when using generic types as entity types.
|
||||
|
// To ensure a better exception is thrown, a manual check is made here.
|
||||
|
if (typeof(TToken).IsGenericType) |
||||
|
{ |
||||
|
throw new InvalidOperationException(new StringBuilder() |
||||
|
.AppendLine("The token entity cannot be a generic type.") |
||||
|
.Append("Consider creating a non-generic derived class.") |
||||
|
.ToString()); |
||||
|
} |
||||
|
|
||||
|
// Warning: optional foreign keys MUST NOT be added as CLR properties because
|
||||
|
// Entity Framework would throw an exception due to the TKey generic parameter
|
||||
|
// being non-nullable when using value types like short, int, long or Guid.
|
||||
|
|
||||
|
HasKey(token => token.Id); |
||||
|
|
||||
|
Property(token => token.ConcurrencyToken) |
||||
|
.IsConcurrencyToken(); |
||||
|
|
||||
|
Property(token => token.ReferenceId) |
||||
|
.HasMaxLength(450) |
||||
|
.HasColumnAnnotation(IndexAnnotation.AnnotationName, new IndexAnnotation(new IndexAttribute())); |
||||
|
|
||||
|
Property(token => token.Subject) |
||||
|
.IsRequired(); |
||||
|
|
||||
|
Property(token => token.Type) |
||||
|
.IsRequired(); |
||||
|
|
||||
|
ToTable("OpenIddictTokens"); |
||||
|
} |
||||
|
} |
||||
|
} |
||||
@ -0,0 +1,67 @@ |
|||||
|
/* |
||||
|
* Licensed under the Apache License, Version 2.0 (http://www.apache.org/licenses/LICENSE-2.0)
|
||||
|
* See https://github.com/openiddict/openiddict-core for more information concerning
|
||||
|
* the license and the contributors participating to this project. |
||||
|
*/ |
||||
|
|
||||
|
using System; |
||||
|
using System.ComponentModel; |
||||
|
using Microsoft.EntityFrameworkCore; |
||||
|
using Microsoft.EntityFrameworkCore.Metadata.Builders; |
||||
|
using OpenIddict.EntityFrameworkCore.Models; |
||||
|
|
||||
|
namespace OpenIddict.EntityFrameworkCore |
||||
|
{ |
||||
|
/// <summary>
|
||||
|
/// Defines a relational mapping for the Application entity.
|
||||
|
/// </summary>
|
||||
|
/// <typeparam name="TApplication">The type of the Application entity.</typeparam>
|
||||
|
/// <typeparam name="TAuthorization">The type of the Authorization entity.</typeparam>
|
||||
|
/// <typeparam name="TToken">The type of the Token entity.</typeparam>
|
||||
|
/// <typeparam name="TKey">The type of the Key entity.</typeparam>
|
||||
|
[EditorBrowsable(EditorBrowsableState.Never)] |
||||
|
public class OpenIddictApplicationConfiguration<TApplication, TAuthorization, TToken, TKey> |
||||
|
where TApplication : OpenIddictApplication<TKey, TAuthorization, TToken> |
||||
|
where TAuthorization : OpenIddictAuthorization<TKey, TApplication, TToken> |
||||
|
where TToken : OpenIddictToken<TKey, TApplication, TAuthorization> |
||||
|
where TKey : IEquatable<TKey> |
||||
|
{ |
||||
|
public void Configure(EntityTypeBuilder<TApplication> builder) |
||||
|
{ |
||||
|
if (builder == null) |
||||
|
{ |
||||
|
throw new ArgumentNullException(nameof(builder)); |
||||
|
} |
||||
|
|
||||
|
// Warning: optional foreign keys MUST NOT be added as CLR properties because
|
||||
|
// Entity Framework would throw an exception due to the TKey generic parameter
|
||||
|
// being non-nullable when using value types like short, int, long or Guid.
|
||||
|
|
||||
|
builder.HasKey(application => application.Id); |
||||
|
|
||||
|
builder.HasIndex(application => application.ClientId) |
||||
|
.IsUnique(); |
||||
|
|
||||
|
builder.Property(application => application.ClientId) |
||||
|
.IsRequired(); |
||||
|
|
||||
|
builder.Property(application => application.ConcurrencyToken) |
||||
|
.IsConcurrencyToken(); |
||||
|
|
||||
|
builder.Property(application => application.Type) |
||||
|
.IsRequired(); |
||||
|
|
||||
|
builder.HasMany(application => application.Authorizations) |
||||
|
.WithOne(authorization => authorization.Application) |
||||
|
.HasForeignKey("ApplicationId") |
||||
|
.IsRequired(required: false); |
||||
|
|
||||
|
builder.HasMany(application => application.Tokens) |
||||
|
.WithOne(token => token.Application) |
||||
|
.HasForeignKey("ApplicationId") |
||||
|
.IsRequired(required: false); |
||||
|
|
||||
|
builder.ToTable("OpenIddictApplications"); |
||||
|
} |
||||
|
} |
||||
|
} |
||||
@ -0,0 +1,62 @@ |
|||||
|
/* |
||||
|
* Licensed under the Apache License, Version 2.0 (http://www.apache.org/licenses/LICENSE-2.0)
|
||||
|
* See https://github.com/openiddict/openiddict-core for more information concerning
|
||||
|
* the license and the contributors participating to this project. |
||||
|
*/ |
||||
|
|
||||
|
using System; |
||||
|
using System.ComponentModel; |
||||
|
using Microsoft.EntityFrameworkCore; |
||||
|
using Microsoft.EntityFrameworkCore.Metadata.Builders; |
||||
|
using OpenIddict.EntityFrameworkCore.Models; |
||||
|
|
||||
|
namespace OpenIddict.EntityFrameworkCore |
||||
|
{ |
||||
|
/// <summary>
|
||||
|
/// Defines a relational mapping for the Authorization entity.
|
||||
|
/// </summary>
|
||||
|
/// <typeparam name="TAuthorization">The type of the Authorization entity.</typeparam>
|
||||
|
/// <typeparam name="TApplication">The type of the Application entity.</typeparam>
|
||||
|
/// <typeparam name="TToken">The type of the Token entity.</typeparam>
|
||||
|
/// <typeparam name="TKey">The type of the Key entity.</typeparam>
|
||||
|
[EditorBrowsable(EditorBrowsableState.Never)] |
||||
|
public class OpenIddictAuthorizationConfiguration<TAuthorization, TApplication, TToken, TKey> |
||||
|
where TAuthorization : OpenIddictAuthorization<TKey, TApplication, TToken> |
||||
|
where TApplication : OpenIddictApplication<TKey, TAuthorization, TToken> |
||||
|
where TToken : OpenIddictToken<TKey, TApplication, TAuthorization> |
||||
|
where TKey : IEquatable<TKey> |
||||
|
{ |
||||
|
public void Configure(EntityTypeBuilder<TAuthorization> builder) |
||||
|
{ |
||||
|
if (builder == null) |
||||
|
{ |
||||
|
throw new ArgumentNullException(nameof(builder)); |
||||
|
} |
||||
|
|
||||
|
// Warning: optional foreign keys MUST NOT be added as CLR properties because
|
||||
|
// Entity Framework would throw an exception due to the TKey generic parameter
|
||||
|
// being non-nullable when using value types like short, int, long or Guid.
|
||||
|
|
||||
|
builder.HasKey(authorization => authorization.Id); |
||||
|
|
||||
|
builder.Property(authorization => authorization.ConcurrencyToken) |
||||
|
.IsConcurrencyToken(); |
||||
|
|
||||
|
builder.Property(authorization => authorization.Status) |
||||
|
.IsRequired(); |
||||
|
|
||||
|
builder.Property(authorization => authorization.Subject) |
||||
|
.IsRequired(); |
||||
|
|
||||
|
builder.Property(authorization => authorization.Type) |
||||
|
.IsRequired(); |
||||
|
|
||||
|
builder.HasMany(authorization => authorization.Tokens) |
||||
|
.WithOne(token => token.Authorization) |
||||
|
.HasForeignKey("AuthorizationId") |
||||
|
.IsRequired(required: false); |
||||
|
|
||||
|
builder.ToTable("OpenIddictAuthorizations"); |
||||
|
} |
||||
|
} |
||||
|
} |
||||
@ -0,0 +1,50 @@ |
|||||
|
/* |
||||
|
* Licensed under the Apache License, Version 2.0 (http://www.apache.org/licenses/LICENSE-2.0)
|
||||
|
* See https://github.com/openiddict/openiddict-core for more information concerning
|
||||
|
* the license and the contributors participating to this project. |
||||
|
*/ |
||||
|
|
||||
|
using System; |
||||
|
using System.ComponentModel; |
||||
|
using Microsoft.EntityFrameworkCore; |
||||
|
using Microsoft.EntityFrameworkCore.Metadata.Builders; |
||||
|
using OpenIddict.EntityFrameworkCore.Models; |
||||
|
|
||||
|
namespace OpenIddict.EntityFrameworkCore |
||||
|
{ |
||||
|
/// <summary>
|
||||
|
/// Defines a relational mapping for the Scope entity.
|
||||
|
/// </summary>
|
||||
|
/// <typeparam name="TScope">The type of the Scope entity.</typeparam>
|
||||
|
/// <typeparam name="TKey">The type of the Key entity.</typeparam>
|
||||
|
[EditorBrowsable(EditorBrowsableState.Never)] |
||||
|
public class OpenIddictScopeConfiguration<TScope, TKey> |
||||
|
where TScope : OpenIddictScope<TKey> |
||||
|
where TKey : IEquatable<TKey> |
||||
|
{ |
||||
|
public void Configure(EntityTypeBuilder<TScope> builder) |
||||
|
{ |
||||
|
if (builder == null) |
||||
|
{ |
||||
|
throw new ArgumentNullException(nameof(builder)); |
||||
|
} |
||||
|
|
||||
|
// Warning: optional foreign keys MUST NOT be added as CLR properties because
|
||||
|
// Entity Framework would throw an exception due to the TKey generic parameter
|
||||
|
// being non-nullable when using value types like short, int, long or Guid.
|
||||
|
|
||||
|
builder.HasKey(scope => scope.Id); |
||||
|
|
||||
|
builder.HasIndex(scope => scope.Name) |
||||
|
.IsUnique(); |
||||
|
|
||||
|
builder.Property(scope => scope.ConcurrencyToken) |
||||
|
.IsConcurrencyToken(); |
||||
|
|
||||
|
builder.Property(scope => scope.Name) |
||||
|
.IsRequired(); |
||||
|
|
||||
|
builder.ToTable("OpenIddictScopes"); |
||||
|
} |
||||
|
} |
||||
|
} |
||||
@ -0,0 +1,57 @@ |
|||||
|
/* |
||||
|
* Licensed under the Apache License, Version 2.0 (http://www.apache.org/licenses/LICENSE-2.0)
|
||||
|
* See https://github.com/openiddict/openiddict-core for more information concerning
|
||||
|
* the license and the contributors participating to this project. |
||||
|
*/ |
||||
|
|
||||
|
using System; |
||||
|
using System.ComponentModel; |
||||
|
using Microsoft.EntityFrameworkCore; |
||||
|
using Microsoft.EntityFrameworkCore.Metadata.Builders; |
||||
|
using OpenIddict.EntityFrameworkCore.Models; |
||||
|
|
||||
|
namespace OpenIddict.EntityFrameworkCore |
||||
|
{ |
||||
|
/// <summary>
|
||||
|
/// Defines a relational mapping for the Token entity.
|
||||
|
/// </summary>
|
||||
|
/// <typeparam name="TToken">The type of the Token entity.</typeparam>
|
||||
|
/// <typeparam name="TApplication">The type of the Application entity.</typeparam>
|
||||
|
/// <typeparam name="TAuthorization">The type of the Authorization entity.</typeparam>
|
||||
|
/// <typeparam name="TKey">The type of the Key entity.</typeparam>
|
||||
|
[EditorBrowsable(EditorBrowsableState.Never)] |
||||
|
public class OpenIddictTokenConfiguration<TToken, TApplication, TAuthorization, TKey> |
||||
|
where TToken : OpenIddictToken<TKey, TApplication, TAuthorization> |
||||
|
where TApplication : OpenIddictApplication<TKey, TAuthorization, TToken> |
||||
|
where TAuthorization : OpenIddictAuthorization<TKey, TApplication, TToken> |
||||
|
where TKey : IEquatable<TKey> |
||||
|
{ |
||||
|
public void Configure(EntityTypeBuilder<TToken> builder) |
||||
|
{ |
||||
|
if (builder == null) |
||||
|
{ |
||||
|
throw new ArgumentNullException(nameof(builder)); |
||||
|
} |
||||
|
|
||||
|
// Warning: optional foreign keys MUST NOT be added as CLR properties because
|
||||
|
// Entity Framework would throw an exception due to the TKey generic parameter
|
||||
|
// being non-nullable when using value types like short, int, long or Guid.
|
||||
|
|
||||
|
builder.HasKey(token => token.Id); |
||||
|
|
||||
|
builder.HasIndex(token => token.ReferenceId) |
||||
|
.IsUnique(); |
||||
|
|
||||
|
builder.Property(token => token.ConcurrencyToken) |
||||
|
.IsConcurrencyToken(); |
||||
|
|
||||
|
builder.Property(token => token.Subject) |
||||
|
.IsRequired(); |
||||
|
|
||||
|
builder.Property(token => token.Type) |
||||
|
.IsRequired(); |
||||
|
|
||||
|
builder.ToTable("OpenIddictTokens"); |
||||
|
} |
||||
|
} |
||||
|
} |
||||
Loading…
Reference in new issue