首页 > 解决方案 > 不支持关键字:“服务器”-身份服务器

问题描述

我正在尝试完成 identityserver4 教程。示例继续使用 sqlite,但我尝试转换为托管在 azure 上的 sqlserver。那时,我遇到了这个错误。

Keyword not supported: 'server'

尽管连接字符串指向 sql server,并且种子方法引用 sqlserver 方法而不是 sqlite,但仍会发生这种情况。

    //services.AddDbContext<ApplicationDbContext>(options =>
    //   options.UseSqlite(connectionString));
    services.AddDbContext<ApplicationDbContext>(options =>
        options.UseSqlServer(connectionString));

[还有其他问题具有相同的错误,但这是专门针对身份服务器的]

标签: asp.net-identityidentityserver4

解决方案


我发现,有两个地方引用了 sql server。

连同 Seed.cs 文件一起,转到 Startup.cs 文件。你会发现另一种用法。

    services.AddDbContext<ApplicationDbContext>(options =>
        options.UseSqlServer(Configuration.GetConnectionString("DefaultConnection")));

这将消除这个问题。


推荐阅读