小编Tes*_*spy的帖子

访问 Microsoft.Extensions.HostingServices 时出错。无法解析 JSON 文件

我试图使用 Visual Studio 2019 为 MVC ASP.NET Core 3.10 项目创建迁移。我遇到两个错误:

  1. 访问 Microsoft.Extensions.Hosting 服务时出错。在没有应用程序服务提供商的情况下继续。错误:无法解析 JSON 文件。
  2. 尚未为此 DbContext 配置数据库提供程序。可以通过覆盖 DbContext.OnConfiguring 方法或在应用程序服务提供者上使用 AddDbContext 来配置提供者。如果使用 AddDbContext,则还要确保您的 DbContext 类型在其构造函数中接受 DbContextOptions 对象并将其传递给 DbContext 的基本构造函数。

我认为第一个是问题,因为我已经按照第二个要求设置了 DbContext。

到目前为止我尝试过的:

  1. 回滚到 .NET Core 3.0
  2. 使用“InitialCreate”以外的名称进行迁移。
  3. 通过 NuGet 包管理器安装 EntityFrameworkCore.Design、EntityFrameworkCore.SQlite、EntityFrameworkCore.SQlServer、EntityFrameworkCore.Logging.Debug、EntityFrameworkCore.Tools
  4. 重新启动计算机并重试
  5. 四重检查 Startup.cs 是否添加了我的 DbContext,并且我的 DbContext 的构造函数设置为在其构造函数中采用 DbContextOptions,将输入传递给基本构造函数

我应该如何处理第一个错误?

c# asp.net-mvc json visual-studio-2010 entity-framework-core

13
推荐指数
3
解决办法
2万
查看次数

TypeError [ERR_UNKNOWN_FILE_EXTENSION]: Visual Studio Code 上的未知文件扩展名“.ts”

我一直在对一些代码进行单元测试,但似乎无处可去,我收到了关于未知文件扩展名的错误(之前,我收到了有关如何无法识别某些类型的错误)。

这是我的 package.json:

{
  "name": "cgt-core-engine-mv",
  "description": "API container for other CGT plugins",
  "version": "1.01.03",
  "author": "CG-Tespy",
  "repository": {
    "type": "git",
    "url": "https://github.com/CG-Tespy/CGT_CoreEngine_MV"
  },
  "scripts": {
    "build": "tsc & (rollup -c)",
    "test": "mocha -r ts-node/register Test/**/*.ts"
  },
  "dependencies": {},
  "devDependencies": {
    "@types/chai": "^4.2.12",
    "@types/mocha": "^8.0.0",
    "@types/sinon": "^9.0.4",
    "chai": "^4.2.0",
    "mocha": "^8.0.1",
    "rollup": "^2.00.1",
    "rollup-plugin-node-resolve": "^5.2.0",
    "rollup-pluginutils": "^2.8.2",
    "sinon": "^9.0.2",
    "ts-node": "^8.10.2",
    "typescript": "^3.9.6"
  },
  "type": "module"
}
Run Code Online (Sandbox Code Playgroud)

这是我的 tsconfig.json:

{
    "compilerOptions": {
      "target": "es5",
      "module": "CommonJS",
      "esModuleInterop": true,

      "sourceMap": false, …
Run Code Online (Sandbox Code Playgroud)

unit-testing typescript visual-studio-code

7
推荐指数
1
解决办法
3972
查看次数

如何使用 Ruby 的字符串分割方法在输出中包含换行符?

这里有这段代码:

thing = "Stuff.\nHello!"
result = thing.split(" ")
# ^Is equal to ["Stuff.", "Hello!"] despite the delimiter being a single space instead of a newline
Run Code Online (Sandbox Code Playgroud)

如何才能包含换行符,使结果 var 等于 ["Stuff.\n", "Hello!"] ?

我正在使用 Ruby 1.9.2。对于那些好奇的人,我需要知道这一点,因为自动换行算法用换行符替换换行符标签。

ruby string ruby-1.9.2

1
推荐指数
1
解决办法
62
查看次数