4

I upgraded from .NET Core 1.1 to .NET Core 2.0 and encountered the following issue (I also upgraded a few libraries to support .net core 2.0 aswell)

CS1929 'ConfigurationStoreOptions' does not contain a definition for 'UseNpgsql' and the best extension method overload 'NpgsqlDbContextOptionsExtensions.UseNpgsql(DbContextOptionsBuilder, string, Action)' requires a receiver of type 'DbContextOptionsBuilder'

Startup.cs

        services.AddIdentityServer()
            .AddSigningCredential(Certificate.Get())
            .AddAspNetIdentity<User>()
            .AddConfigurationStore(builder =>
                builder.UseNpgsql(connectionString, options =>
                    options.MigrationsAssembly(migrationsAssembly)))
            .AddOperationalStore(builder =>
                builder.UseNpgsql(connectionString, options =>
                    options.MigrationsAssembly(migrationsAssembly)));

Same issue when using UseSqlServer

// configure identity server with in-memory users, but EF stores for clients and resources
services.AddIdentityServer()
    .AddTemporarySigningCredential()
    .AddTestUsers(Config.GetUsers())
    .AddConfigurationStore(builder =>
        builder.UseSqlServer(connectionString, options =>
            options.MigrationsAssembly(migrationsAssembly)))
    .AddOperationalStore(builder =>
        builder.UseSqlServer(connectionString, options =>
            options.MigrationsAssembly(migrationsAssembly)));

http://docs.identityserver.io/en/release/quickstarts/8_entity_framework.html

Note: I have added "using Microsoft.EntityFrameworkCore;"

1
  • 2.0.0 RC1 was just released to nuget that targets netstandard 2.0 Commented Sep 5, 2017 at 12:46

2 Answers 2

12

Solution:

        services.AddIdentityServer()
            .AddSigningCredential(Certificate.Get())
            .AddAspNetIdentity<User>()
            .AddConfigurationStore(options =>
            {
                options.ConfigureDbContext = builder =>
                    builder.UseNpgsql(connectionString,
                        sql => sql.MigrationsAssembly(migrationsAssembly));
            })
            // this adds the operational data from DB (codes, tokens, consents)
            .AddOperationalStore(options =>
            {
                options.ConfigureDbContext = builder =>
                    builder.UseNpgsql(connectionString,
                        sql => sql.MigrationsAssembly(migrationsAssembly));

                // this enables automatic token cleanup. this is optional.
                options.EnableTokenCleanup = true;
                options.TokenCleanupInterval = 30;
            });
Sign up to request clarification or add additional context in comments.

Comments

0

Just encountered the same problem myself. A trawling of the IndentityServer4.EntityFramework github revealed an example Startup.cs making the use of the ConfigureDBContext property

Comments

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Start asking to get answers

Find the answer to your question by asking.

Ask question

Explore related questions

See similar questions with these tags.