Warnings when using the SimpleIdServer samples
Hi,
Thanks very much for an amazing project. I've been playing around with the samples as per documentation:
dotnet new idserver -n IdServer
In general it has worked quite well, but I could not help but notice a large number of warnings in the logs:
warn: Microsoft.EntityFrameworkCore.Model.Validation[10620]
The property 'AuditEvent.Claims' is a collection or enumeration type with a value converter but with no value comparer. Set a value comparer to ensure the collection/enumeration elements are compared correctly.
warn: Microsoft.EntityFrameworkCore.Model.Validation[10620]
The property 'AuditEvent.Scopes' is a collection or enumeration type with a value converter but with no value comparer. Set a value comparer to ensure the collection/enumeration elements are compared correctly.
warn: Microsoft.EntityFrameworkCore.Model.Validation[10620]
The property 'BCAuthorize.Scopes' is a collection or enumeration type with a value converter but with no value comparer. Set a value comparer to ensure the collection/enumeration elements are compared correctly.
warn: Microsoft.EntityFrameworkCore.Model.Validation[10620]
The property 'Client.AuthorizationDataTypes' is a collection or enumeration type with a value converter but with no value comparer. Set a value comparer to ensure the collection/enumeration elements are compared correctly.
warn: Microsoft.EntityFrameworkCore.Model.Validation[10620]
The property 'Client.ClientRegistrationTypesSupported' is a collection or enumeration type with a value converter but with no value comparer. Set a value comparer to ensure the collection/enumeration elements are compared correctly.
warn: Microsoft.EntityFrameworkCore.Model.Validation[10620]
The property 'Client.Contacts' is a collection or enumeration type with a value converter but with no value comparer. Set a value comparer to ensure the collection/enumeration elements are compared correctly.
warn: Microsoft.EntityFrameworkCore.Model.Validation[10620]
The property 'Client.DefaultAcrValues' is a collection or enumeration type with a value converter but with no value comparer. Set a value comparer to ensure the collection/enumeration elements are compared correctly.
warn: Microsoft.EntityFrameworkCore.
<SNIP>
The property 'Template.Windows' is a collection or enumeration type with a value converter but with no value comparer. Set a value comparer to ensure the collection/enumeration elements are compared correctly.
warn: Microsoft.EntityFrameworkCore.Model.Validation[10625]
The foreign key property 'TemplateStyle.TemplateId1' was created in shadow state because a conflicting property with the simple name 'TemplateId' exists in the entity type, but is either not mapped, is already used for another relationship, or is incompatible with the associated primary key type. See https://aka.ms/efcore-relationships for information on mapping relationships in EF Core.
warn: Microsoft.EntityFrameworkCore.Query[20504]
Compiling a query which loads related collections for more than one collection navigation, either via 'Include' or through projection, but no 'QuerySplittingBehavior' has been configured. By default, Entity Framework will use 'QuerySplittingBehavior.SingleQuery', which can potentially result in slow query performance. See https://go.microsoft.com/fwlink/?linkid=2134277 for more information. To identify the query that's triggering this warning call 'ConfigureWarnings(w => w.Throw(RelationalEventId.MultipleCollectionIncludeWarning))'.
User is authenticated
I noticed this issue was mentioned in the context of a migration (EF5 to EF6) but that does not appear to be the case with my code, since I am doing a fresh start:
- https://github.com/simpleidserver/SimpleIdServer/issues/291
Any thoughts on this are appreciated. Many thanks for your time.
By the by, I asked Claude Code for some assistance with this and it came up with the following - not sure if helpful or not.
The Entity Framework warning about "collection or enumeration type with a value converter but with no value comparer" is about how EF Core handles equality comparisons for collection properties that are stored in the database.
What's Happening
When you have a collection property like List
- Convert it for storage - Turn the collection into a format the database can store (like JSON string or comma-separated values)
- Compare it for changes - Detect when the collection has been modified to know when to update the database
The Problem
SimpleIdServer has configured value converters for these collections (to serialize/deserialize them), but hasn't provided value comparers. This means:
- ✅ Storage works fine - Collections get converted to/from database format correctly
- ⚠ Change detection is suboptimal - EF uses default reference equality instead of content equality
Example
// In SimpleIdServer's entity configuration
entity.Property(e => e.Claims)
.HasConversion(
// Convert List<string> to JSON for database
claims => JsonSerializer.Serialize(claims),
// Convert JSON back to List<string>
json => JsonSerializer.Deserialize<List<string>>(json)
);
// ❌ Missing: .HasConversion(..., valueComparer)
The Issue
Without a value comparer, EF Core can't properly detect changes:
var auditEvent = context.AuditEvents.First();
auditEvent.Claims.Add("new-claim"); // Modifies the list content
// EF might not detect this change because it only checks if the
// Claims property reference changed, not if the list contents changed
context.SaveChanges(); // Might not save the new claim!
The Fix (What Should Be Done)
entity.Property(e => e.Claims)
.HasConversion(
claims => JsonSerializer.Serialize(claims),
json => JsonSerializer.Deserialize<List<string>>(json),
// ✅ Add value comparer for proper change detection
new ValueComparer<List<string>>(
(c1, c2) => c1.SequenceEqual(c2), // Compare contents
c => c.Aggregate(0, (a, v) => HashCode.Combine(a, v.GetHashCode())), // Hash
c => c.ToList() // Snapshot
)
);
Why We Suppressed It
Since this is in SimpleIdServer's library code (not ours), we can't fix it directly. The warnings don't break functionality - they just mean change tracking isn't optimal for these collection properties. Suppressing the warnings is the cleanest solution until SimpleIdServer fixes them in a future version.
In case this is of interest to anyone else, the suppression was as follows:
// Suppress Entity Framework value comparer warnings from SimpleIdServer
webApplicationBuilder.Logging.AddFilter(
"Microsoft.EntityFrameworkCore.Model.Validation",
LogLevel.Error
);
I am not terribly happy with it as it could possibly hide other warnings that may be significant.
Hello @mcraveiro ,
First, thank you for your investigation. The warning message "The property <> is a collection or enumeration type with a value converter" is now resolved in the release/v6.0.3 branch.
Comparers have been added in the various EF configuration files.
KR,
SID