不支持连接字符串关键字 'server' 数据库迁移

Connection string keyword 'server' is not supported DB Migration

我在尝试迁移命令时遇到此错误:

Add-Migration AddAuthentication

Update-Database

我已经添加了所有正确的 nugget 包,所以我不知道错误的来源。

这是我的 startup.cs :

public class Startup
    {
        public Startup(IConfiguration configuration)
        {
            Configuration = configuration;
        }

        public IConfiguration Configuration { get; }

        // This method gets called by the runtime. Use this method to add services to the container.
        public void ConfigureServices(IServiceCollection services)
        {

            services.AddRazorPages();

            services.AddDbContext<AuthDbContext>(options => options.UseSqlServer(Configuration.GetConnectionString("AuthConnectionString")));

            services.AddIdentity<IdentityUser, IdentityRole>().AddEntityFrameworkStores<AuthDbContext>();

        }

        // This method gets called by the runtime. Use this method to configure the HTTP request pipeline.
        public void Configure(IApplicationBuilder app, IWebHostEnvironment env)
        {
            if (env.IsDevelopment())
            {
                app.UseDeveloperExceptionPage();
            }
            else
            {
                app.UseExceptionHandler("/Error");
                // The default HSTS value is 30 days. You may want to change this for production scenarios, see https://aka.ms/aspnetcore-hsts.
                app.UseHsts();
            }

            app.UseHttpsRedirection();
            app.UseStaticFiles();

            app.UseRouting();

            app.UseAuthentication();

            app.UseAuthorization();

            app.UseEndpoints(endpoints =>
            {
                endpoints.MapRazorPages();
            });
        }
    

这是我的模特:

public class AuthDbContext : IdentityDbContext
    {
        public AuthDbContext(DbContextOptions<AuthDbContext> options) : base(options)
        {

        }

这是连接字符串:

"ConnectionStrings": {
    "AuthConnectionString": "Server=.;Database=AspNetAuth;Trusted_Connection=True"
  }
}

感谢您的宝贵时间!

我将此连接字符串用于本地 sql 服务器

"Data Source=localhost;Initial Catalog=xxxx;Integrated Security=SSPI;Persist Security Info=True;"