代码之家  ›  专栏  ›  技术社区  ›  Santosh Jha

IdentityServer4.存储-没有声明模型

  •  0
  • Santosh Jha  · 技术社区  · 8 年前

    我使用下面的解决方案为Identity Server 4创建管理。 https://github.com/IdentityServer/IdentityServer4.Storage/tree/2.3.0-preview1-update2 但我有一些问题如下-

    1. 如何将现有的DBcontext(ConfigurationDbContext)用于 迁移并用于凝乳操作。至于在MVC核心中创建视图,我们需要一个模型类。
    2. 在上面的解决方案中,我们没有索赔模型-那么如何创建 表(单位:DB)。她说,我们需要创造自己的环境。
    3. 如果我们要使用Asp.net身份核心进行用户管理,那么 用户声明和中出现的声明之间的关系是什么 ID4。
    4. 我们是否需要在上述解决方案中创建自己的DB上下文并 迁移。

    请建议一些教程-我是新来的。我已经去了官方网站,但没有发现任何与行政管理有关的东西。 我已经编写了一些代码来创建迁移,如下所示

     public class DbContextStorage : DbContext
    {
        public DbContextStorage(DbContextOptions<DbContextStorage> options) : base(options)
        {
    
        }
        //protected override void OnConfiguring(DbContextOptionsBuilder optionsBuilder)
        //{
        //    optionsBuilder.UseSqlServer(ConfigurationManager.ConnectionStrings["IdentityServerDatabase"].ConnectionString);
        //}
        public virtual DbSet<ApiResource> ApiResource { get; set; }
        public virtual DbSet<AuthorizationCode> AuthorizationCode { get; set; }
        public virtual DbSet<Client> Clients { get; set;  }
        public virtual DbSet<Consent> Consents { get; set; }
        public virtual DbSet<IdentityResource> IdentityResource { get; set; }
    
        public virtual DbSet<PersistedGrant> PersistedGrant { get; set; }
    
        public virtual DbSet<RefreshToken> RefreshToken { get; set; }
        public virtual DbSet<Resource> Resource { get; set; }
        public virtual DbSet<Resources> Resources { get; set; }
        public virtual DbSet<Scope> Scope { get; set; }
    
        public virtual DbSet<Secret> Secret { get; set; }
    
        public virtual DbSet<Token> Token { get; set; }
    
    }
    

    添加迁移初始值

    System.InvalidOperationException: No suitable constructor found for entity type 'Claim'. The following parameters could not be bound to properties of the entity: 'reader', 'reader', 'subject', 'type', 'value', 'type', 'value', 'valueType', 'type', 'value', 'valueType', 'issuer', 'type', 'value', 'valueType', 'issuer', 'originalIssuer', 'type', 'value', 'valueType', 'issuer', 'originalIssuer', 'subject', 'type', 'value', 'valueType', 'issuer', 'originalIssuer', 'subject', 'propertyKey', 'propertyValue', 'other', 'other', 'subject'.
       at Microsoft.EntityFrameworkCore.Metadata.Conventions.Internal.ConstructorBindingConvention.Apply(InternalModelBuilder modelBuilder)
       at Microsoft.EntityFrameworkCore.Metadata.Conventions.Internal.ConventionDispatcher.ImmediateConventionScope.OnModelBuilt(InternalModelBuilder modelBuilder)
       at Microsoft.EntityFrameworkCore.Infrastructure.ModelSource.CreateModel(DbContext context, IConventionSetBuilder conventionSetBuilder, IModelValidator validator)
       at System.Lazy`1.ViaFactory(LazyThreadSafetyMode mode)
       at System.Lazy`1.ExecutionAndPublication(LazyHelper executionAndPublication, Boolean useDefaultConstructor)
       at System.Lazy`1.CreateValue()
       at Microsoft.EntityFrameworkCore.Internal.DbContextServices.CreateModel()
       at Microsoft.EntityFrameworkCore.Internal.DbContextServices.get_Model()
       at Microsoft.Extensions.DependencyInjection.ServiceLookup.CallSiteRuntimeResolver.VisitFactory(FactoryCallSite factoryCallSite, ServiceProviderEngineScope scope)
       at Microsoft.Extensions.DependencyInjection.ServiceLookup.CallSiteVisitor`2.VisitCallSite(IServiceCallSite callSite, TArgument argument)
       at Microsoft.Extensions.DependencyInjection.ServiceLookup.CallSiteRuntimeResolver.VisitScoped(ScopedCallSite scopedCallSite, ServiceProviderEngineScope scope)
       at Microsoft.Extensions.DependencyInjection.ServiceLookup.CallSiteVisitor`2.VisitCallSite(IServiceCallSite callSite, TArgument argument)
       at Microsoft.Extensions.DependencyInjection.ServiceLookup.CallSiteRuntimeResolver.VisitConstructor(ConstructorCallSite constructorCallSite, ServiceProviderEngineScope scope)
       at Microsoft.Extensions.DependencyInjection.ServiceLookup.CallSiteVisitor`2.VisitCallSite(IServiceCallSite callSite, TArgument argument)
       at Microsoft.Extensions.DependencyInjection.ServiceLookup.CallSiteRuntimeResolver.VisitScoped(ScopedCallSite scopedCallSite, ServiceProviderEngineScope scope)
       at Microsoft.Extensions.DependencyInjection.ServiceLookup.CallSiteVisitor`2.VisitCallSite(IServiceCallSite callSite, TArgument argument)
       at Microsoft.Extensions.DependencyInjection.ServiceLookup.DynamicServiceProviderEngine.<>c__DisplayClass1_0.<RealizeService>b__0(ServiceProviderEngineScope scope)
       at Microsoft.Extensions.DependencyInjection.ServiceLookup.ServiceProviderEngine.GetService(Type serviceType, ServiceProviderEngineScope serviceProviderEngineScope)
       at Microsoft.Extensions.DependencyInjection.ServiceLookup.ServiceProviderEngineScope.GetService(Type serviceType)
       at Microsoft.Extensions.DependencyInjection.ServiceProviderServiceExtensions.GetRequiredService(IServiceProvider provider, Type serviceType)
       at Microsoft.Extensions.DependencyInjection.ServiceProviderServiceExtensions.GetRequiredService[T](IServiceProvider provider)
       at Microsoft.EntityFrameworkCore.DbContext.get_DbContextDependencies()
       at Microsoft.EntityFrameworkCore.DbContext.get_InternalServiceProvider()
       at Microsoft.EntityFrameworkCore.Internal.InternalAccessorExtensions.GetService[TService](IInfrastructure`1 accessor)
       at Microsoft.EntityFrameworkCore.Design.Internal.DbContextOperations.CreateContext(Func`1 factory)
       at Microsoft.EntityFrameworkCore.Design.Internal.DbContextOperations.CreateContext(String contextType)
       at Microsoft.EntityFrameworkCore.Design.Internal.MigrationsOperations.AddMigration(String name, String outputDir, String contextType)
       at Microsoft.EntityFrameworkCore.Design.OperationExecutor.AddMigrationImpl(String name, String outputDir, String contextType)
       at Microsoft.EntityFrameworkCore.Design.OperationExecutor.AddMigration.<>c__DisplayClass0_1.<.ctor>b__0()
       at Microsoft.EntityFrameworkCore.Design.OperationExecutor.OperationBase.<>c__DisplayClass3_0`1.<Execute>b__0()
       at Microsoft.EntityFrameworkCore.Design.OperationExecutor.OperationBase.Execute(Action action)
    No suitable constructor found for entity type 'Claim'. The following parameters could not be bound to properties of the entity: 'reader', 'reader', 'subject', 'type', 'value', 'type', 'value', 'valueType', 'type', 'value', 'valueType', 'issuer', 'type', 'value', 'valueType', 'issuer', 'originalIssuer', 'type', 'value', 'valueType', 'issuer', 'originalIssuer', 'subject', 'type', 'value', 'valueType', 'issuer', 'originalIssuer', 'subject', 'propertyKey', 'propertyValue', 'other', 'other', 'subject'.
    

    我认为我无法找到正确的方向来为Identity server4创建管理模块。

    1 回复  |  直到 8 年前
        1
  •  1
  •   Mike Anderson    8 年前

    在我看来,您需要有一个用于管理的客户端应用程序,因此您有两个使用DB的web应用程序(idsrv、idsrvmanager),在这里您可以决定从idsrv或idsrvmanager运行迁移的位置。 看看 this repository