使用.Include()时在Postman中“无法获得任何响应”

时间:2018-10-08 11:05:21

标签: c# entity-framework postman

在MVC控制器的HttpGet方法中,我有这样一条语句:

IEnumerable<UserExtension> iue = await DataContext.UserExtensions;

如果我将命令更改为:

IEnumerable<UserExtension> iue = DataContext.UserExtensions.Include(ue => ue.UserRoles)

代码中没有引发异常,但是我在邮递员中得到了以下响应:

Could not get any response

There was an error connecting to http://localhost:60891/table/UserExtension.
Why this might have happened:
The server couldn't send a response:
Ensure that the backend is working properly
Self-signed SSL certificates are being blocked:
Fix this by turning off 'SSL certificate verification' in Settings > General
Proxy configured incorrectly
Ensure that proxy is configured correctly in Settings > Proxy
Request timeout:
Change request timeout in Settings > General

为什么会发生这种情况?

没有.Include()子句,一切正常,并且UserRoles返回NULL,如预期。

1 个答案:

答案 0 :(得分:0)

您确定没有例外吗?这听起来像try / catch块“吞噬了”异常。 您可以尝试调试应用程序以了解正在发生的事情?

数据中的某些内容可能与您的模型不一致。例如。代码中的1-1关系在数据库中具有1-n个项目。

发布用于检索数据的代码可以帮助我们找出问题所在。