首页
学习
活动
专区
圈层
工具
发布
社区首页 >问答首页 >ASP.Net核心3.1 Web API (ApiController),EF核心3.1 {系统找不到指定的文件。}

ASP.Net核心3.1 Web API (ApiController),EF核心3.1 {系统找不到指定的文件。}
EN

Stack Overflow用户
提问于 2020-09-08 22:51:51
回答 1查看 114关注 0票数 0

我以前做过几个.net核心应用编程接口的EF核心。事实上,我已经在https://github.com/xmione/.Net-Core-2.2上创建了一个可用的.Net Core2.2版本。

现在,我尝试为core api和ef core编写core3.1。当然,每一个都有自己独立的项目。我可以很好地完成添加-迁移和更新-数据库。数据库和表将自动创建。我还可以访问weatherforcast api方法,它完美地显示了数据。UseInMemoryDatabase的工作也很棒。但是当我开始做UseSqlServer()的时候。这就是我遇到错误的时候:

代码语言:javascript
复制
Win32Exception: The system cannot find the file specified.
Unknown location

SqlException: A network-related or instance-specific error occurred while establishing a connection to SQL Server. The server was not found or was not accessible. Verify that the instance name is correct and that SQL Server is configured to allow remote connections. (provider: SNI_PN11, error: 52 - Unable to locate a Local Database Runtime installation. Verify that SQL Server Express is properly installed and that the Local Database Runtime feature is enabled.)
Microsoft.Data.SqlClient.SqlInternalConnection.OnError(SqlException exception, bool breakConnection, Action<Action> wrapCloseInAction)

我可以在Visual Studio和SQL Server Management Studio中看到创建的数据库和表,并且我可以操作它,添加、编辑和删除记录。但是当我运行API并对其进行测试时。它会失败并显示上面的错误。有人能告诉我这里最快的方向吗?谢谢。我的代码位于以下链接:

https://github.com/xmione/ReactJS/tree/master/ReactJS.Redux.Web.API/API

非常感谢!

EN

回答 1

Stack Overflow用户

回答已采纳

发布于 2020-09-10 23:58:09

我刚想好怎么解决这个问题。我只是在https://code-maze.com/net-core-web-api-ef-core-code-first/上关注了这篇文章。实际上在Github.com上有一个源代码:https://github.com/CodeMazeBlog/ef-code-first

我只是遵循了这篇文章,下载了源代码并将其与我的代码进行了比较。我发现我遗漏了一些重要的Repository类。

多亏了那篇文章,我用Github.com编写的代码已经修复了。我的Web API源代码在:https://github.com/xmione/ReactJS/tree/master/ReactJS.Redux.Web.API,我希望这对需要它的人有所帮助。

票数 0
EN
页面原文内容由Stack Overflow提供。腾讯云小微IT领域专用引擎提供翻译支持
原文链接:

https://stackoverflow.com/questions/63796451

复制
相关文章

相似问题

领券
问题归档专栏文章快讯文章归档关键词归档开发者手册归档开发者手册 Section 归档