问题描述
这是我第一次尝试使用带有代码优先方法的存储库模式的 .net 核心 Web API(基于令牌)。
迁移现在也有效。 唯一的问题是作为我试图从数据库中检索数据的第一步。然后我从我的 Repository 类中得到这个错误
我有这种架构。
但我不知道为什么我会得到这个。它在 asp.net MVC 上工作。但在 asp.net core 中它是完全不同的。
我已经将此项目上传到 Github。
安装相关的 NuGet 包后,请先运行迁移
通过选择存储库项目
(您可以在 appsettings.json 中更改数据库配置)之后,请运行该项目。
在你的邮递员那里发布这个
https://localhost:5001/api/name/authenticate
{ "用户名":"test1",“密码”:“密码1” }
然后你会得到一个令牌。
之后,通过提供该令牌来尝试 GET。
https://localhost:5001/api/inventory
此时,它将调用 InventoryController Get
这是我遇到的那个错误。
如果您有任何想法,请立即告诉我,我已将所有代码发布到 git。
能够通过删除 MyServicesDbContext 中的参数构造函数来解决此问题。 但我不认为那不是我期望的方式。
解决方法
暂无找到可以解决该程序问题的有效方法,小编努力寻找整理中!
如果你已经找到好的解决方法,欢迎将解决方案带上本链接一起发送给小编。
小编邮箱:dio#foxmail.com (将#修改为@)