diff --git a/src/OpenIddict.EntityFramework.Models/OpenIddict.EntityFramework.Models.csproj b/src/OpenIddict.EntityFramework.Models/OpenIddict.EntityFramework.Models.csproj
index c23bd436..44052d81 100644
--- a/src/OpenIddict.EntityFramework.Models/OpenIddict.EntityFramework.Models.csproj
+++ b/src/OpenIddict.EntityFramework.Models/OpenIddict.EntityFramework.Models.csproj
@@ -2,6 +2,7 @@
net461;netstandard2.0
+ enable
diff --git a/src/OpenIddict.EntityFramework.Models/OpenIddictEntityFrameworkApplication.cs b/src/OpenIddict.EntityFramework.Models/OpenIddictEntityFrameworkApplication.cs
index f9e9b29d..2e998737 100644
--- a/src/OpenIddict.EntityFramework.Models/OpenIddictEntityFrameworkApplication.cs
+++ b/src/OpenIddict.EntityFramework.Models/OpenIddictEntityFrameworkApplication.cs
@@ -7,6 +7,7 @@
using System;
using System.Collections.Generic;
using System.Diagnostics;
+using System.Diagnostics.CodeAnalysis;
namespace OpenIddict.EntityFramework.Models
{
@@ -26,7 +27,10 @@ namespace OpenIddict.EntityFramework.Models
/// Represents an OpenIddict application.
///
[DebuggerDisplay("Id = {Id.ToString(),nq} ; ClientId = {ClientId,nq} ; Type = {Type,nq}")]
- public class OpenIddictEntityFrameworkApplication where TKey : IEquatable
+ public class OpenIddictEntityFrameworkApplication
+ where TKey : notnull, IEquatable
+ where TAuthorization : class
+ where TToken : class
{
///
/// Gets the list of the authorizations associated with this application.
@@ -34,77 +38,74 @@ namespace OpenIddict.EntityFramework.Models
public virtual ICollection Authorizations { get; } = new HashSet();
///
- /// Gets or sets the client identifier
- /// associated with the current application.
+ /// Gets or sets the client identifier associated with the current application.
///
- public virtual string ClientId { get; set; }
+ public virtual string? ClientId { get; set; }
///
/// Gets or sets the client secret associated with the current application.
/// Note: depending on the application manager used to create this instance,
/// this property may be hashed or encrypted for security reasons.
///
- public virtual string ClientSecret { get; set; }
+ public virtual string? ClientSecret { get; set; }
///
/// Gets or sets the concurrency token.
///
- public virtual string ConcurrencyToken { get; set; } = Guid.NewGuid().ToString();
+ public virtual string? ConcurrencyToken { get; set; } = Guid.NewGuid().ToString();
///
- /// Gets or sets the consent type
- /// associated with the current application.
+ /// Gets or sets the consent type associated with the current application.
///
- public virtual string ConsentType { get; set; }
+ public virtual string? ConsentType { get; set; }
///
- /// Gets or sets the display name
- /// associated with the current application.
+ /// Gets or sets the display name associated with the current application.
///
- public virtual string DisplayName { get; set; }
+ public virtual string? DisplayName { get; set; }
///
/// Gets or sets the localized display names
/// associated with the current application,
/// serialized as a JSON object.
///
- public virtual string DisplayNames { get; set; }
+ public virtual string? DisplayNames { get; set; }
///
- /// Gets or sets the unique identifier
- /// associated with the current application.
+ /// Gets or sets the unique identifier associated with the current application.
///
- public virtual TKey Id { get; set; }
+ [AllowNull, MaybeNull]
+ public virtual TKey Id { get; set; } = default!;
///
/// Gets or sets the permissions associated with the
/// current application, serialized as a JSON array.
///
- public virtual string Permissions { get; set; }
+ public virtual string? Permissions { get; set; }
///
/// Gets or sets the logout callback URLs associated with
/// the current application, serialized as a JSON array.
///
- public virtual string PostLogoutRedirectUris { get; set; }
+ public virtual string? PostLogoutRedirectUris { get; set; }
///
/// Gets or sets the additional properties serialized as a JSON object,
/// or null if no bag was associated with the current application.
///
- public virtual string Properties { get; set; }
+ public virtual string? Properties { get; set; }
///
/// Gets or sets the callback URLs associated with the
/// current application, serialized as a JSON array.
///
- public virtual string RedirectUris { get; set; }
+ public virtual string? RedirectUris { get; set; }
///
/// Gets or sets the requirements associated with the
/// current application, serialized as a JSON array.
///
- public virtual string Requirements { get; set; }
+ public virtual string? Requirements { get; set; }
///
/// Gets the list of the tokens associated with this application.
@@ -112,9 +113,8 @@ namespace OpenIddict.EntityFramework.Models
public virtual ICollection Tokens { get; } = new HashSet();
///
- /// Gets or sets the application type
- /// associated with the current application.
+ /// Gets or sets the application type associated with the current application.
///
- public virtual string Type { get; set; }
+ public virtual string? Type { get; set; }
}
}
\ No newline at end of file
diff --git a/src/OpenIddict.EntityFramework.Models/OpenIddictEntityFrameworkAuthorization.cs b/src/OpenIddict.EntityFramework.Models/OpenIddictEntityFrameworkAuthorization.cs
index a5a5ccc4..cb18cf81 100644
--- a/src/OpenIddict.EntityFramework.Models/OpenIddictEntityFrameworkAuthorization.cs
+++ b/src/OpenIddict.EntityFramework.Models/OpenIddictEntityFrameworkAuthorization.cs
@@ -7,6 +7,7 @@
using System;
using System.Collections.Generic;
using System.Diagnostics;
+using System.Diagnostics.CodeAnalysis;
namespace OpenIddict.EntityFramework.Models
{
@@ -26,45 +27,48 @@ namespace OpenIddict.EntityFramework.Models
/// Represents an OpenIddict authorization.
///
[DebuggerDisplay("Id = {Id.ToString(),nq} ; Subject = {Subject,nq} ; Type = {Type,nq} ; Status = {Status,nq}")]
- public class OpenIddictEntityFrameworkAuthorization where TKey : IEquatable
+ public class OpenIddictEntityFrameworkAuthorization
+ where TKey : notnull, IEquatable
+ where TApplication : class
+ where TToken : class
{
///
/// Gets or sets the application associated with the current authorization.
///
- public virtual TApplication Application { get; set; }
+ public virtual TApplication? Application { get; set; }
///
/// Gets or sets the concurrency token.
///
- public virtual string ConcurrencyToken { get; set; } = Guid.NewGuid().ToString();
+ public virtual string? ConcurrencyToken { get; set; } = Guid.NewGuid().ToString();
///
- /// Gets or sets the unique identifier
- /// associated with the current authorization.
+ /// Gets or sets the unique identifier associated with the current authorization.
///
- public virtual TKey Id { get; set; }
+ [AllowNull, MaybeNull]
+ public virtual TKey Id { get; set; } = default!;
///
/// Gets or sets the additional properties serialized as a JSON object,
/// or null if no bag was associated with the current authorization.
///
- public virtual string Properties { get; set; }
+ public virtual string? Properties { get; set; }
///
/// Gets or sets the scopes associated with the current
/// authorization, serialized as a JSON array.
///
- public virtual string Scopes { get; set; }
+ public virtual string? Scopes { get; set; }
///
/// Gets or sets the status of the current authorization.
///
- public virtual string Status { get; set; }
+ public virtual string? Status { get; set; }
///
/// Gets or sets the subject associated with the current authorization.
///
- public virtual string Subject { get; set; }
+ public virtual string? Subject { get; set; }
///
/// Gets the list of tokens associated with the current authorization.
@@ -74,6 +78,6 @@ namespace OpenIddict.EntityFramework.Models
///
/// Gets or sets the type of the current authorization.
///
- public virtual string Type { get; set; }
+ public virtual string? Type { get; set; }
}
}
diff --git a/src/OpenIddict.EntityFramework.Models/OpenIddictEntityFrameworkScope.cs b/src/OpenIddict.EntityFramework.Models/OpenIddictEntityFrameworkScope.cs
index 9f719c28..04ab550e 100644
--- a/src/OpenIddict.EntityFramework.Models/OpenIddictEntityFrameworkScope.cs
+++ b/src/OpenIddict.EntityFramework.Models/OpenIddictEntityFrameworkScope.cs
@@ -6,6 +6,7 @@
using System;
using System.Diagnostics;
+using System.Diagnostics.CodeAnalysis;
namespace OpenIddict.EntityFramework.Models
{
@@ -25,60 +26,57 @@ namespace OpenIddict.EntityFramework.Models
/// Represents an OpenIddict scope.
///
[DebuggerDisplay("Id = {Id.ToString(),nq} ; Name = {Name,nq}")]
- public class OpenIddictEntityFrameworkScope where TKey : IEquatable
+ public class OpenIddictEntityFrameworkScope where TKey : notnull, IEquatable
{
///
/// Gets or sets the concurrency token.
///
- public virtual string ConcurrencyToken { get; set; } = Guid.NewGuid().ToString();
+ public virtual string? ConcurrencyToken { get; set; } = Guid.NewGuid().ToString();
///
- /// Gets or sets the public description
- /// associated with the current scope.
+ /// Gets or sets the public description associated with the current scope.
///
- public virtual string Description { get; set; }
+ public virtual string? Description { get; set; }
///
/// Gets or sets the localized public descriptions associated
/// with the current scope, serialized as a JSON object.
///
- public virtual string Descriptions { get; set; }
+ public virtual string? Descriptions { get; set; }
///
- /// Gets or sets the display name
- /// associated with the current scope.
+ /// Gets or sets the display name associated with the current scope.
///
- public virtual string DisplayName { get; set; }
+ public virtual string? DisplayName { get; set; }
///
/// Gets or sets the localized display names
/// associated with the current application,
/// serialized as a JSON object.
///
- public virtual string DisplayNames { get; set; }
+ public virtual string? DisplayNames { get; set; }
///
- /// Gets or sets the unique identifier
- /// associated with the current scope.
+ /// Gets or sets the unique identifier associated with the current scope.
///
- public virtual TKey Id { get; set; }
+ [AllowNull, MaybeNull]
+ public virtual TKey Id { get; set; } = default!;
///
- /// Gets or sets the unique name
- /// associated with the current scope.
+ /// Gets or sets the unique name associated with the current scope.
///
- public virtual string Name { get; set; }
+ public virtual string? Name { get; set; }
///
/// Gets or sets the additional properties serialized as a JSON object,
/// or null if no bag was associated with the current scope.
///
- public virtual string Properties { get; set; }
+ public virtual string? Properties { get; set; }
///
/// Gets or sets the resources associated with the
/// current scope, serialized as a JSON array.
///
- public virtual string Resources { get; set; }
+ public virtual string? Resources { get; set; }
}
}
diff --git a/src/OpenIddict.EntityFramework.Models/OpenIddictEntityFrameworkToken.cs b/src/OpenIddict.EntityFramework.Models/OpenIddictEntityFrameworkToken.cs
index ba1226d5..c264753d 100644
--- a/src/OpenIddict.EntityFramework.Models/OpenIddictEntityFrameworkToken.cs
+++ b/src/OpenIddict.EntityFramework.Models/OpenIddictEntityFrameworkToken.cs
@@ -6,6 +6,7 @@
using System;
using System.Diagnostics;
+using System.Diagnostics.CodeAnalysis;
namespace OpenIddict.EntityFramework.Models
{
@@ -25,53 +26,54 @@ namespace OpenIddict.EntityFramework.Models
/// Represents an OpenIddict token.
///
[DebuggerDisplay("Id = {Id.ToString(),nq} ; Subject = {Subject,nq} ; Type = {Type,nq} ; Status = {Status,nq}")]
- public class OpenIddictEntityFrameworkToken where TKey : IEquatable
+ public class OpenIddictEntityFrameworkToken
+ where TKey : notnull, IEquatable
+ where TApplication : class
+ where TAuthorization : class
{
///
/// Gets or sets the application associated with the current token.
///
- public virtual TApplication Application { get; set; }
+ public virtual TApplication? Application { get; set; }
///
/// Gets or sets the authorization associated with the current token.
///
- public virtual TAuthorization Authorization { get; set; }
+ public virtual TAuthorization? Authorization { get; set; }
///
/// Gets or sets the concurrency token.
///
- public virtual string ConcurrencyToken { get; set; } = Guid.NewGuid().ToString();
+ public virtual string? ConcurrencyToken { get; set; } = Guid.NewGuid().ToString();
///
- /// Gets or sets the date on which the token
- /// will start to be considered valid.
+ /// Gets or sets the date on which the token will start to be considered valid.
///
public virtual DateTimeOffset? CreationDate { get; set; }
///
- /// Gets or sets the date on which the token
- /// will no longer be considered valid.
+ /// Gets or sets the date on which the token will no longer be considered valid.
///
public virtual DateTimeOffset? ExpirationDate { get; set; }
///
- /// Gets or sets the unique identifier
- /// associated with the current token.
+ /// Gets or sets the unique identifier associated with the current token.
///
- public virtual TKey Id { get; set; }
+ [AllowNull, MaybeNull]
+ public virtual TKey Id { get; set; } = default!;
///
/// Gets or sets the payload of the current token, if applicable.
/// Note: this property is only used for reference tokens
/// and may be encrypted for security reasons.
///
- public virtual string Payload { get; set; }
+ public virtual string? Payload { get; set; }
///
/// Gets or sets the additional properties serialized as a JSON object,
/// or null if no bag was associated with the current token.
///
- public virtual string Properties { get; set; }
+ public virtual string? Properties { get; set; }
///
/// Gets or sets the reference identifier associated
@@ -79,21 +81,21 @@ namespace OpenIddict.EntityFramework.Models
/// Note: this property is only used for reference tokens
/// and may be hashed or encrypted for security reasons.
///
- public virtual string ReferenceId { get; set; }
+ public virtual string? ReferenceId { get; set; }
///
/// Gets or sets the status of the current token.
///
- public virtual string Status { get; set; }
+ public virtual string? Status { get; set; }
///
/// Gets or sets the subject associated with the current token.
///
- public virtual string Subject { get; set; }
+ public virtual string? Subject { get; set; }
///
/// Gets or sets the type of the current token.
///
- public virtual string Type { get; set; }
+ public virtual string? Type { get; set; }
}
}
diff --git a/src/OpenIddict.EntityFramework/Configurations/OpenIddictEntityFrameworkApplicationConfiguration.cs b/src/OpenIddict.EntityFramework/Configurations/OpenIddictEntityFrameworkApplicationConfiguration.cs
index 2e273e6a..fc8ec31c 100644
--- a/src/OpenIddict.EntityFramework/Configurations/OpenIddictEntityFrameworkApplicationConfiguration.cs
+++ b/src/OpenIddict.EntityFramework/Configurations/OpenIddictEntityFrameworkApplicationConfiguration.cs
@@ -37,7 +37,6 @@ namespace OpenIddict.EntityFramework
Property(application => application.ClientId)
.HasMaxLength(100)
- .IsRequired()
.HasColumnAnnotation(IndexAnnotation.AnnotationName, new IndexAnnotation(new IndexAttribute
{
IsUnique = true
@@ -48,11 +47,10 @@ namespace OpenIddict.EntityFramework
.IsConcurrencyToken();
Property(application => application.Type)
- .HasMaxLength(25)
- .IsRequired();
+ .HasMaxLength(25);
HasMany(application => application.Authorizations)
- .WithOptional(authorization => authorization.Application)
+ .WithOptional(authorization => authorization.Application!)
.Map(association =>
{
association.MapKey(nameof(OpenIddictEntityFrameworkAuthorization.Application) +
@@ -60,7 +58,7 @@ namespace OpenIddict.EntityFramework
});
HasMany(application => application.Tokens)
- .WithOptional(token => token.Application)
+ .WithOptional(token => token.Application!)
.Map(association =>
{
association.MapKey(nameof(OpenIddictEntityFrameworkToken.Application) +
diff --git a/src/OpenIddict.EntityFramework/Configurations/OpenIddictEntityFrameworkAuthorizationConfiguration.cs b/src/OpenIddict.EntityFramework/Configurations/OpenIddictEntityFrameworkAuthorizationConfiguration.cs
index e8286635..8108a763 100644
--- a/src/OpenIddict.EntityFramework/Configurations/OpenIddictEntityFrameworkAuthorizationConfiguration.cs
+++ b/src/OpenIddict.EntityFramework/Configurations/OpenIddictEntityFrameworkAuthorizationConfiguration.cs
@@ -38,18 +38,16 @@ namespace OpenIddict.EntityFramework
.IsConcurrencyToken();
Property(authorization => authorization.Status)
- .HasMaxLength(25)
- .IsRequired();
+ .HasMaxLength(25);
Property(authorization => authorization.Subject)
.HasMaxLength(450);
Property(authorization => authorization.Type)
- .HasMaxLength(25)
- .IsRequired();
+ .HasMaxLength(25);
HasMany(authorization => authorization.Tokens)
- .WithOptional(token => token.Authorization)
+ .WithOptional(token => token.Authorization!)
.Map(association => association.MapKey(nameof(OpenIddictEntityFrameworkToken.Authorization) +
nameof(OpenIddictEntityFrameworkAuthorization.Id)))
.WillCascadeOnDelete();
diff --git a/src/OpenIddict.EntityFramework/Configurations/OpenIddictEntityFrameworkScopeConfiguration.cs b/src/OpenIddict.EntityFramework/Configurations/OpenIddictEntityFrameworkScopeConfiguration.cs
index 5ca05173..625fbb97 100644
--- a/src/OpenIddict.EntityFramework/Configurations/OpenIddictEntityFrameworkScopeConfiguration.cs
+++ b/src/OpenIddict.EntityFramework/Configurations/OpenIddictEntityFrameworkScopeConfiguration.cs
@@ -37,7 +37,6 @@ namespace OpenIddict.EntityFramework
Property(scope => scope.Name)
.HasMaxLength(200)
- .IsRequired()
.HasColumnAnnotation(IndexAnnotation.AnnotationName, new IndexAnnotation(new IndexAttribute
{
IsUnique = true
diff --git a/src/OpenIddict.EntityFramework/Configurations/OpenIddictEntityFrameworkTokenConfiguration.cs b/src/OpenIddict.EntityFramework/Configurations/OpenIddictEntityFrameworkTokenConfiguration.cs
index cea5d127..cf316457 100644
--- a/src/OpenIddict.EntityFramework/Configurations/OpenIddictEntityFrameworkTokenConfiguration.cs
+++ b/src/OpenIddict.EntityFramework/Configurations/OpenIddictEntityFrameworkTokenConfiguration.cs
@@ -47,15 +47,13 @@ namespace OpenIddict.EntityFramework
.HasColumnAnnotation(IndexAnnotation.AnnotationName, new IndexAnnotation(new IndexAttribute()));
Property(token => token.Status)
- .HasMaxLength(25)
- .IsRequired();
+ .HasMaxLength(25);
Property(token => token.Subject)
.HasMaxLength(450);
Property(token => token.Type)
- .HasMaxLength(25)
- .IsRequired();
+ .HasMaxLength(25);
ToTable("OpenIddictTokens");
}