c# - .net core 3.1 with EF Core 错误使用 NetTopologySuite 连接数据库
问题描述
在 appSettings 我有这个:
"ConnectionStrings": {
"GeoLocation": "Server=localhost;Database=GeoLocationDB;Trusted_Connection=True;MultipleActiveResultSets=true;"
}
我在 ConfigureServices 的启动文件中有下一个代码:
services.AddDbContext<GeoLocationContext>(o => o.UseSqlServer(Configuration.GetConnectionString("GeoLocation"), s => s.UseNetTopologySuite()));
在启动的配置方法中添加执行此操作的上下文:
context.Database.Migrate();
得到这个:
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.
奇怪的是我创建了一个迁移并运行更新数据库,它运行没有问题我不知道为什么迁移我没有得到同样的错误。
对于数据库,我可以毫无问题地登录 localhost,并看到在包管理器控制台中执行的迁移生成的更改。
通过 api 控制器(是微服务)中的代码,我尝试进行插入,它给了我同样的错误,我有几天试图理解为什么会发生这种情况,但我找不到问题。
提前致谢
解决方案
推荐阅读
- android - 我可以通过“使用 Apple ID 登录”获取用户的电话号码以进行电话验证吗?
- swift - 无法访问 MTKView
- sql - 如何让我的 PostgresSQL 成功执行调用?
- google-api-js-client - gapi - 如何查看所有电子表格
- python-3.x - 从#1comment 到 #2nd comment 逐行读取文件
- node.js - 未捕获的 ReferenceError:添加 react-hot-loader babel 插件后未定义进程(来自 NodeJS.Process)
- json - ValueNotifier 未处理的异常:类型“String”不是“index”类型“int”的子类型
- python - 'can' BLFReader 函数的 Python 属性错误
- javascript - 从数组对象json更新mongodb的最佳方法是什么?
- java - 要设置的 Java 泛型集合