Home > OS >  Connection string keyword 'server' is not supported DB Migration
Connection string keyword 'server' is not supported DB Migration

Time:02-23

I'm getting this error when I try the migration commands :

Add-Migration AddAuthentication

Update-Database

I've added all the proper nugget packages so I don't know where the error stems from.

Here is my 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();
            });
        }
    

And this is my Model :

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

        }

And here is the connection string :

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

Thank you for your time !

CodePudding user response:

I use this connection string for local sql server

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