导航属性未由EF核心填写 - IdentityServer 4

时间:2017-11-27 12:40:10

标签: c# entity-framework-core identityserver4 eager-loading ef-core-2.0

我有一个案例,我需要能够使用IdentityServer 4客户端进行所有crud操作。似乎没有为此服务所以我正在实施我自己的。

问题在于,当我尝试获取所有客户端时,导航属性由于某种原因未填写。 我正在使用像IdentityServer团队实施的ClientStore中那样的热切加载。

所以我的方法看起来像这样:

....
IList<Client> clients = _configurationDbContext.Clients
                .Include(x => x.ClientSecrets)
                .Include(x => x.RedirectUris)
                .Include(x => x.AllowedScopes)
                .Include(x => x.AllowedGrantTypes)
                .ToList();
....

我无法找到有关其实现的任何特殊内容,但事实是上面的代码没有填充导航属性,但ClientStore在我用它来查找客户端时正在工作。

有谁知道为什么会这样?

更新

回应@Gert Arnold的评论。这是正在执行的SQL:

SELECT [c].[Id], [c].[AbsoluteRefreshTokenLifetime], [c].[AccessTokenLifetime], [c].[AccessTokenType], [c].[AllowAccessTokensViaBrowser], [c].[AllowOfflineAccess], [c].[AllowPlainTextPkce], [c].[AllowRememberConsent], [c].[AlwaysIncludeUserClaimsInIdToken], [c].[AlwaysSendClientClaims], [c].[AuthorizationCodeLifetime], [c].[BackChannelLogoutSessionRequired], [c].[BackChannelLogoutUri], [c].[ClientClaimsPrefix], [c].[ClientId], [c].[ClientName], [c].[ClientUri], [c].[ConsentLifetime], [c].[Description], [c].[EnableLocalLogin], [c].[Enabled], [c].[FrontChannelLogoutSessionRequired], [c].[FrontChannelLogoutUri], [c].[IdentityTokenLifetime], [c].[IncludeJwtId], [c].[LogoUri], [c].[PairWiseSubjectSalt], [c].[ProtocolType], [c].[RefreshTokenExpiration], [c].[RefreshTokenUsage], [c].[RequireClientSecret], [c].[RequireConsent], [c].[RequirePkce], [c].[SlidingRefreshTokenLifetime], [c].[UpdateAccessTokenClaimsOnRefresh]
FROM [Clients] AS [c]

没有应该预期的任何联接。我没有提供更多信息,因为我没有或更准确,我无法想到任何有用的信息。

对我而言,似乎EF核心可能存在一些配置问题。

如果你想到一些可能有用的信息,请告诉我,我会提供。

输出窗口中的整个调试日志:

Microsoft.AspNetCore.Hosting.Internal.WebHost: Information: Request starting HTTP/1.1 POST http://localhost:57919/admin/manageClientsAdmin/list application/x-www-form-urlencoded; charset=UTF-8 182
Microsoft.AspNetCore.Authentication.Cookies.CookieAuthenticationHandler: Information: AuthenticationScheme: Authentication was successfully authenticated.
Microsoft.AspNetCore.Mvc.Internal.ControllerActionInvoker: Information: Executing action method Nop.Plugin.Api.Controllers.Admin.ManageClientsAdminController.List (Nop.Plugin.Api) with arguments (Nop.Web.Framework.Kendoui.DataSourceRequest) - ModelState is Valid
Microsoft.EntityFrameworkCore.Infrastructure: Information: Entity Framework Core 2.0.1-rtm-125 initialized 'ConfigurationDbContext' using provider 'Microsoft.EntityFrameworkCore.SqlServer' with options: MigrationsAssembly=Nop.Plugin.Api 
Microsoft.EntityFrameworkCore.Database.Command: Information: Executed DbCommand (1ms) [Parameters=[], CommandType='Text', CommandTimeout='30']
SELECT [c].[Id], [c].[AbsoluteRefreshTokenLifetime], [c].[AccessTokenLifetime], [c].[AccessTokenType], [c].[AllowAccessTokensViaBrowser], [c].[AllowOfflineAccess], [c].[AllowPlainTextPkce], [c].[AllowRememberConsent], [c].[AlwaysIncludeUserClaimsInIdToken], [c].[AlwaysSendClientClaims], [c].[AuthorizationCodeLifetime], [c].[BackChannelLogoutSessionRequired], [c].[BackChannelLogoutUri], [c].[ClientClaimsPrefix], [c].[ClientId], [c].[ClientName], [c].[ClientUri], [c].[ConsentLifetime], [c].[Description], [c].[EnableLocalLogin], [c].[Enabled], [c].[FrontChannelLogoutSessionRequired], [c].[FrontChannelLogoutUri], [c].[IdentityTokenLifetime], [c].[IncludeJwtId], [c].[LogoUri], [c].[PairWiseSubjectSalt], [c].[ProtocolType], [c].[RefreshTokenExpiration], [c].[RefreshTokenUsage], [c].[RequireClientSecret], [c].[RequireConsent], [c].[RequirePkce], [c].[SlidingRefreshTokenLifetime], [c].[UpdateAccessTokenClaimsOnRefresh]
FROM [Clients] AS [c]
Microsoft.AspNetCore.Mvc.Formatters.Json.Internal.JsonResultExecutor: Information: Executing JsonResult, writing value Nop.Web.Framework.Kendoui.DataSourceResult.
Microsoft.AspNetCore.Mvc.Internal.ControllerActionInvoker: Information: Executed action Nop.Plugin.Api.Controllers.Admin.ManageClientsAdminController.List (Nop.Plugin.Api) in 14.0648ms
Microsoft.AspNetCore.Hosting.Internal.WebHost: Information: Request finished in 17.8712ms 200 application/json; charset=utf-8

0 个答案:

没有答案