【发布时间】:2021-08-14 16:39:43
【问题描述】:
我之前做过几个 .net core api 的 EF Core。事实上,我在这里 https://github.com/xmione/.Net-Core-2.2 创建了一个工作的 .Net Core 2.2 版本。
现在我尝试为 core api 和 ef core 做 core 3.1。每个,当然有它的独立项目。 我可以很好地执行 Add-Migrations 和 Update-Database。数据库和表将自动创建。我还可以访问 weatherforcast api 方法,它完美地显示了数据。 UseInMemoryDatabase 也很棒。但是当我开始做 UseSqlServer() 时。那是我遇到错误的时候:
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
非常感谢!
【问题讨论】:
标签: asp.net-core entity-framework-core