2017-09-07 34 views
0

我希望這是簡單和容易解決的事情。 我已經在現有項目中安裝了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但這並沒有工作。 有誰知道如何解決這個問題?

回答

0

這很簡單,你必須有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。這爲我創造了桌子,而且所有的事情都是蠢蠢欲動的