Home / ASP.NET - MVC / Database connection string

Learn about database connection strings

After creating the Model in the previous articles, you should learn a little about the database connection string in ASP.NET MVC. To view the connection string content, you can open the Web.config file in the project and look for the connectionStrings tag. The contents of a file Web.config are as follows:



  
    
    

The segment that contains the connection strings you need to find:


    

You must pay more attention to the BookStoreManager connection string. This is the connection string by which the Web project understands the database from SQL Server in MVC style.

The three files Models.Model.csdl, Models.Model.ssdl and Models.Model.msl are MVC configuration files. Accordingly, you are using the default SQL server of the machine you are using (data source=HIEPSIITT\VUAVIET)and the database name is initial catalog=BookStore with integrated security mode (integrated security=True), no need for a login account.

You must write down the correct connection string parameters and when actually deploying, you must change the information. For example, if the connection string deployed on a server has a database IP of 192.168.1.1 and has a User login account of "user" and a Password of "pass", you change the connection string as follows:

Next we will access the data model from the controller

Did you find this article helpful?

Support the author so they can write more quality articles!

Tư vấn lộ trình CNTT 🤖