DuendeSoftware / Support

Support for Duende Software products
21 stars 0 forks source link

there are a problem in IdentityServer and Automapper #337

Closed armintodev closed 1 year ago

armintodev commented 1 year ago

Which version of Duende IdentityServer are you using? 6.1.7

Which version of .NET are you using? .Net 7

Describe the bug when I trying to seed some data into IdentityServer tables in database likes Clients,ApiResource,IdentityResource etc... get an excpetion. I using some static data in Config.cs file and use ToEntity() extension method to mapping data.

Log output/exception with stacktrace

Identity Seed has error : The type initializer for 'Duende.IdentityServer.EntityFramework.Mappers.ScopeMappers' threw an exception.

here's my code

public static IEnumerable<ApiScope> ApiScopes =>
        new[] { new ApiScope("Admin"), new ApiScope("Ui"), };
if (!context.ApiScopes.Any())
        {
            foreach (var resource in IdentityServerConfiguration.ApiScopes.ToList())
            {
                context.ApiScopes.Add(resource.ToEntity());
            }

            haveToSaveChanges = true;
        }
josephdecock commented 1 year ago

Is there any more output in the log to understand what exception was thrown?

armintodev commented 1 year ago

@josephdecock problem solved by update IdentityServer packages to RC🙄

josephdecock commented 1 year ago

Okay, I'm glad your issue is solved. We're adding support for .NET 7 in 6.2. Just to confirm, you were getting this problem with IdentityServer 6.1.7 and .NET 7?

armintodev commented 1 year ago

Yes. that's right

josephdecock commented 1 year ago

Thank you!