Home >Backend Development >C#.Net Tutorial >Detailed explanation of usage examples of LocalDB database that comes with VS2015

Detailed explanation of usage examples of LocalDB database that comes with VS2015

零下一度
零下一度Original
2017-06-25 09:18:104675browse

This article mainly introduces in detail the usage of the LocalDB database that comes with VS2015, which has certain reference value. Interested friends can refer to it

For programmers, during the programming process Will more or less deal with the database. If you use Visual Studio for program development, Microsoft's Sql Server database is the best choice. But here comes the problem. The Sql Server database is often several gigabytes in size, and it takes up quite a lot of space after installation. Does every developer need to install Sql Server during development? In fact, for the development of small projects, test projects, and learning projects, there is no need to use a database as tall as Sql Server. Microsoft itself is well aware of this, so it has launched a super simplified version of the Sql Server database: Sql Server LocalDB. This small database can fully meet the development and debugging of ordinary projects. The key is that it is only a few dozen M, which can greatly reduce the operating pressure of the PC. This article will briefly introduce how to use the LocalDB database in Visual Studio 2015.

1. Installation of LocalDB

LocalDB will be automatically installed when installing VS2015, so as long as VS2015 is installed correctly, localDB will definitely be available.

2. LocalDB connection and management

Enter VS2015, select "Sql Server

Object in "View" Resource Manager", you can see the following interface.

Right-click on Sql Server and select "Add Sql Server".

Browse the local area in the pop-up form, and you can see that there are two database instances: MSSQLLocalDB and ProjectsV13. These two instances are LocalDB that comes with VS2015. The reason why there are two is because the poster’s VS2015 has been updated. MSSQLLocalDB belongs to the V12 version of LocalDB, and ProjectsV13 belongs to the V13 version of LocalDB. Both of them can currently be used by VS2015. engineering use. Next, take MSSQLLocalDB as an example to connect. After successful connection, the resource manager on the left can manage the resources of the database.

Then we can try to create a new database Test.

After the Test database is successfully created, the database can be operated normally. However, if you want to connect to an external database file, you cannot directly operate it in the Sql Server Resource Manager. In this case, you need to operate it in the Server Resource Manager. The process is as follows:

Choose to add a connection in the server resource manager. If the external database file is directly connected, the file will be attached to LocalDB by default:

Select "Browse" in the pop-up form to add an external database file:

After selecting the file and clicking "OK", there will be an additional external database file in the server resource manager. Database file connection:

Check MSSQLLocalDB in the Sql Server Object Explorer again. You can see that the external database just added is attached to this

local database. 中:

At this point, the external database has also been attached. If you want to connect to the database in the project, the connection

string is as follows:

"Data Source=(LocalDB)\\MSSQLLocalDB;AttachDbFilename=The absolute path of the external database file (note the escape character)".

The above is the detailed content of Detailed explanation of usage examples of LocalDB database that comes with VS2015. For more information, please follow other related articles on the PHP Chinese website!

Statement:
The content of this article is voluntarily contributed by netizens, and the copyright belongs to the original author. This site does not assume corresponding legal responsibility. If you find any content suspected of plagiarism or infringement, please contact admin@php.cn