简体   繁体   中英

ASP.NET Core MVC Changing Connection String does not work

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.

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.

The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM