将ASP.NET Boilerplate模块零与IdentityServer4

时间:2016-12-16 07:31:17

标签: c# .net asp.net-core-1.0 identityserver4 asp.net-boilerplate

我尝试将IdentityServer4与ASP.NET Boilerplate模块一起使用,但我遇到了一些错误

我试图关注此链接 http://docs.identityserver.io/en/release/quickstarts/6_aspnet_identity.html

我的ConfigureServices功能

public IServiceProvider ConfigureServices(IServiceCollection services)
    {
        var connectionString = @"Server=localhost\SQLEXPRESS; 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?}");
        });
    }

在运行应用程序后,我收到此错误

  

&#39; Microsoft.AspNetCore.Identity.UserManager1 [[EventoTix.Users.User,   EventoTix.Core,Version = 1.0.0.0,Culture = neutral,   公钥=空]] _ b66a8aa6-a49b-47c6-A3B3-d6e943ee4c47&#39;在等待   对于以下依赖项:    - 服务&#39; Microsoft.AspNetCore.Identity.IUserStore1 [[EventoTix.Users.User,   EventoTix.Core,Version = 1.0.0.0,Culture = neutral,   公钥=空]]&#39;没有注册。

2 个答案:

答案 0 :(得分:1)

我得到了HalilİbrahimKalkan的回答

他说模块零模板使用的是EF 6.x,而不是EF Core。此外,Abp.Zero包基于Identity 2.x,而不是Identity Core。所以,他们不兼容。

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

答案 1 :(得分:0)

尝试安装 https://www.nuget.org/packages/Microsoft.AspNetCore.Identity/ 在nuget经理。

如果没有帮助,请关闭解决方案,找到解决方案文件夹,打包文件夹,删除所有内容,再次打开u解决方案,转到nuget包管理器并单击“恢复”