IdentityServer3与EntityFramework

问题描述:

我希望这是简单和容易解决的事情。 我已经在现有项目中安装了IdentityServer3,并设法让“内存”中的内容正常工作。 现在我连接到我的UserManager。当我尝试验证,我得到这个错误:IdentityServer3与EntityFramework

"One or more validation errors were detected during model generation:\r\n\r\nCormar.Sql.Claim: : EntityType 'Claim' has no key defined. Define the key for this EntityType.\r\nCormar.Sql.ClaimsIdentity: : EntityType 'ClaimsIdentity' has no key defined. Define the key for this EntityType.\r\nCormar.Sql.IdentityReference: : EntityType 'IdentityReference' has no key defined. Define the key for this EntityType.\r\nCormar.Sql.Secret: : EntityType 'Secret' has no key defined. Define the key for this EntityType.\r\nCormar.Sql.RefreshToken: : EntityType 'RefreshToken' has no key defined. Define the key for this EntityType.\r\nCormar.Sql.Token: : EntityType 'Token' has no key defined. Define the key for this EntityType.\r\nCormar.Sql.Scope: : EntityType 'Scope' has no key defined. Define the key for this EntityType.\r\nCormar.Sql.ScopeClaim: : EntityType 'ScopeClaim' has no key defined. Define the key for this EntityType.\r\nClaims: EntityType: EntitySet 'Claims' is based on type 'Claim' that has no keys defined.\r\nClaimsIdentities: EntityType: EntitySet 'ClaimsIdentities' is based on type 'ClaimsIdentity' that has no keys defined.\r\nIdentityReferences: EntityType: EntitySet 'IdentityReferences' is based on type 'IdentityReference' that has no keys defined.\r\nSecrets: EntityType: EntitySet 'Secrets' is based on type 'Secret' that has no keys defined.\r\nRefreshTokens: EntityType: EntitySet 'RefreshTokens' is based on type 'RefreshToken' that has no keys defined.\r\nTokens: EntityType: EntitySet 'Tokens' is based on type 'Token' that has no keys defined.\r\nScopes: EntityType: EntitySet 'Scopes' is based on type 'Scope' that has no keys defined.\r\nScopeClaims: EntityType: EntitySet 'ScopeClaims' is based on type 'ScopeClaim' that has no keys defined.\r\n"

我想这可能是因为我错过了一个包,所以我用的NuGet安装IdentityServer3.EntityFramework但这并没有工作。 有谁知道如何解决这个问题?

这很简单,你必须有IdentityServer3.EntityFramework。我看了看源,看到移民类,所以我只是简单地添加了实体我的DbContext这样的:

public DbSet<Client> Clients { get; set; } 
public DbSet<ClientClaim> ClientClaims { get; set; } 
public DbSet<ClientSecret> ClientSecrets { get; set; } 
public DbSet<Consent> Consents { get; set; } 
public DbSet<Scope> Scopes { get; set; } 
public DbSet<ScopeClaim> ScopeClaims { get; set; } 

然后我做了一个add-migrationupdate-database。这为我创造了桌子,而且所有的事情都是蠢蠢欲动的