Home > Software engineering >  ASP.NET Core MVC Changing Connection String does not work
ASP.NET Core MVC Changing Connection String does not work

Time:03-12

I'm new to ASP.Net Core and I'm in the process of moving my MS sql database from my localhost to a Linux server. I changed the connection string to point to the new database but the issues is that the code will not reflect the changes, it is still trying to use the old database. Is the connection string in the appsettings.json file the only change that I need to make or is there other changes that I need to make? I have no idea where the code is pulling the old connection string.

CodePudding user response:

If you are using EFCore you may have this in your DbContext:

protected override void OnConfiguring(DbContextOptionsBuilder optionsBuilder)
    {
        if (!optionsBuilder.IsConfigured)                
            optionsBuilder.UseSqlServer(
               "sqlconnstring");
    }

Might just need to update it there mate.

  • Related