项目第一次运行时,构建初始值时出现此错误。
**System.TypeInitializationException:“‘IdentityServer4.EntityFramework.Mappers.IdentityResourceMappers’的类型初始值设定项引发了异常。”
1-VerificationException:方法 System.Linq.Enumerable.MaxFloat:类型参数“System.Char”违反了类型参数“T”的约束。**
2-ArgumentException:“T MaxFloatT”上的 GenericArguments[0]、“System.Char”违反了类型“T”的约束。*
这是我的数据:
var identityResources = new List<IdentityResource>()
{
new IdentityResources.OpenId(),
new IdentityResource("profile","profile", new[]
{
ClaimTypes.NameIdentifier,
JwtClaimTypes.Role
}),
};
context.IdentityResources.AddRange(identityResources.Select(m => m.ToEntity()));
我找到了答案。 在 .Net 7 中存在错误
IdentityServer4.EntityFramework.Mappers.IdentityResourceMappers
IdentityServer4 应该可以解决它。