J
J
justbefree2018-02-09 12:20:55
IIS
justbefree, 2018-02-09 12:20:55

Connecting to ms sql database in asp NET application?

There is an application on asp.NET. There was a need to change it (and its base) a little. I made a copy of the application and the database. I edit the web.config file at the root. I launch a copy of the application, but it still works with the old database.
The base of the original Phones in web.config is connected like this

<connectionStrings>
        <remove name="LocalSqlServer" />
    <add connectionString="Server=SERVERBD;Database=Phones;Integrated Security=true" name="PhonesConnectionString" providerName="System.Data.SqlClient" />
    <add connectionString="Server=SERVERBD;Database=Phones;Integrated Security=true" name="PhonesConnectionString2" providerName="System.Data.SqlClient" />
    <add connectionString="Server=SERVERBD;Database=Phones;Integrated Security=true" name="PhonesConnectionString3" providerName="System.Data.SqlClient" />
        <add connectionString="Server=SERVERBD;Database=Phones;Integrated Security=true" name="LocalSqlServer" providerName="System.Data.SqlClient" />
  </connectionStrings>

Accordingly, in the copy, I simply changed the name of the base
<connectionStrings>
        <remove name="LocalSqlServer" />
    <add connectionString="Server=SERVERBD;Database=Phones_test;Integrated Security=true" name="PhonesConnectionString" providerName="System.Data.SqlClient" />
    <add connectionString="Server=SERVERBD;Database=Phones_test;Integrated Security=true" name="PhonesConnectionString2" providerName="System.Data.SqlClient" />
    <add connectionString="Server=SERVERBD;Database=Phones_test;Integrated Security=true" name="PhonesConnectionString3" providerName="System.Data.SqlClient" />
        <add connectionString="Server=SERVERBD;Database=Phones_test;Integrated Security=true" name="LocalSqlServer" providerName="System.Data.SqlClient" />
  </connectionStrings>

How and where can I change the connection to the database?

Answer the question

In order to leave comments, you need to log in

1 answer(s)
A
Alyosha, 2018-02-09
@digna

Check the model and controller in the project (do you have such tables and columns in the database. The name of the model must match the name of the table in the database, as well as the columns with fields inside the class), if everything is ok, then go to the NuGet command line and execute there this command Add-Migration *title* and then Update-Database. If it doesn’t work out before the evening, you want to write to VK https://vk.com/dignatukhin in the evening I’ll come home from work and help. If you really need it urgently, then look at the office. manual https://docs.microsoft.com/ru-ru/aspnet/core/tutor...

Didn't find what you were looking for?

Ask your question

Ask a Question

731 491 924 answers to any question