将ASP.NET样板模块集成使用IdentityServer4



我正在尝试使用ASP.NET样板模块零使用IdentityServer4,但我会遇到一些错误

我正在尝试遵循此链接http://docs.sideityserver.io/en/release/quickstarts/6_aspnet_identity.html

我的配置服务功能

public IServiceProvider ConfigureServices(IServiceCollection services)
    {
        var connectionString = @"Server=localhostSQLEXPRESS; Database=MyDb;User Id=sa; password=sa;";
        // configure identity server with in-memory users, but EF stores for clients and resources
        var migrationsAssembly = typeof(Startup).GetTypeInfo().Assembly.GetName().Name;
        services.AddIdentityServer()
           .AddTemporarySigningCredential()
           .AddConfigurationStore(builder =>
               builder.UseSqlServer(connectionString, options =>
                   options.MigrationsAssembly(migrationsAssembly)))
           .AddOperationalStore(builder =>
               builder.UseSqlServer(connectionString, options =>
                   options.MigrationsAssembly(migrationsAssembly)))
                   .AddAspNetIdentity<User>();
        //MVC
        services.AddMvc(options =>
        {
            options.Filters.Add(new AutoValidateAntiforgeryTokenAttribute());
        });
        services.AddIdentity<User, Role>();

        //Configure Abp and Dependency Injection
        return services.AddAbp<EventoTixWebModule>(options =>
        {
            //Configure Log4Net logging
            options.IocManager.IocContainer.AddFacility<LoggingFacility>(
                f => f.UseAbpLog4Net().WithConfig("log4net.config")
            );
        });
    }

我的配置函数

public void Configure(IApplicationBuilder app, IHostingEnvironment env,         ILoggerFactory loggerFactory)
    {
        // this will do the initial DB population
        InitializeDatabase(app);
        //loggerFactory.AddConsole(Configuration.GetSection("Logging"));
        //loggerFactory.AddDebug();
        app.UseAbp(); //Initializes ABP framework.
        if (env.IsDevelopment())
        {
            app.UseDeveloperExceptionPage();
            //app.UseDatabaseErrorPage();
            app.UseBrowserLink();
        }
        else
        {
            app.UseExceptionHandler("/Home/Error");
        }
        app.UseStaticFiles();
        //Integrate to OWIN
        app.UseAppBuilder(ConfigureOwinServices);
        //app.UseIdentity();
        app.UseIdentityServer();

        app.UseMvc(routes =>
        {
            routes.MapRoute(
                name: "default",
                template: "{controller=Home}/{action=Index}/{id?}");
        });
    }

运行应用程序后,我会遇到此错误

'Microsoft.aspnetcore.Identity.usermanager1 [[Eventotix.users.user, Eventotix.Core,版本= 1.0.0.0,culture =中性, publicKeyToken = null]] _ B66A8AA6-A49B-47C6-A3B3-D6E943EE4C47'正在等待 对于以下依赖性: - 服务'Microsoft.aspnetcore.Identity.iuserStore1 [[Eventotix.users.user, Eventotix.Core,版本= 1.0.0.0,culture =中性, publicKeyToken = null]]'未注册。

我得到了HalilİbrahimKalkan

的答案

他说模块零模板使用EF 6.x,而不是EF核心。另外,abp.Zero软件包基于身份2.x,而不是身份核心。因此,它们不兼容。

参考:https://github.com/aspnetboilerplate/aspnetboilerplate/issues/961

尝试安装https://www.nuget.org/packages/microsoft.aspnetcore.identity/在Nuget Manager中。

如果没有帮助,请关闭解决方案,查找解决方案文件夹,包装文件夹,删除全部,再次打开U解决方案,转到Nuget Package Manager,然后单击" Restore"

最新更新