Detailed usage of the built-in LocalDB database in VS2015, vs2015localdb

Source: Internet
Author: User

Detailed usage of the built-in LocalDB database in VS2015, vs2015localdb

Programmers are more or less involved in programming with databases. If Visual Studio is used for program development, Microsoft's SQL Server database is the best choice. But the problem is that the SQL Server database is usually several GB, and the space occupied after installation is quite large. Is it necessary for every developer 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 databases as high as SQL Server. Microsoft knows this well. Therefore, it has launched the SQL Server database super simplified version: SQL Server LocalDB. This small database can fully meet the development and debugging needs of common projects. The key is that it only has dozens of MB, which can greatly reduce the running pressure on PCs. This article briefly introduces how to use the LocalDB database in Visual Studio 2015.

1. Install LocalDB

LocalDB is automatically installed when VS2015 is installed. Therefore, localDB must be installed correctly.

Ii. Connection and Management of LocalDB

Go to VS2015 and select "SQL Server Object Resource Manager" in "View". The following page is displayed.

Right-click SQL Server and select "add SQL Server ".

You can view the local data in the pop-up window and see two database instances: MSSQLLocalDB and ProjectsV13. Both instances are built-in LocalDB in VS2015. The reason is that the original version of VS2015 has been updated. MSSQLLocalDB is a LocalDB of V12 and ProjectsV13 is a LocalDB of V13, both of them can be used by VS2015 projects. Next we will use MSSQLLocalDB as an example to connect. After successful connection, the resource manager on the Left can manage the database resources.

Then we can try to create a new database named Test.

After the Test database is successfully created, the database can be operated normally. However, if you want to connect to external database files, you cannot perform operations directly in the SQL Server resource manager. In this case, you need to perform operations in the Server resource manager. The process is as follows:

In the server resource manager, select Add connection. If you connect directly to an external database file, the file will be appended to LocalDB by default:

In the pop-up form, select Browse to add an external database file:

After selecting the file, click "OK". The server resource manager adds an external database file connection:

Check MSSQLLocalDB in the SQL Server Object resource manager again. You can see that the added external database is appended to this local database:

Now, the external database has been attached. If you want to connect to the database in the project, the connection string is as follows:

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

The above is all the content of this article. I hope it will be helpful for your learning and support for helping customers.

Related Article

Contact Us

The content source of this page is from Internet, which doesn't represent Alibaba Cloud's opinion; products and services mentioned on that page don't have any relationship with Alibaba Cloud. If the content of the page makes you feel confusing, please write us an email, we will handle the problem within 5 days after receiving your email.

If you find any instances of plagiarism from the community, please send an email to: info-contact@alibabacloud.com and provide relevant evidence. A staff member will contact you within 5 working days.

A Free Trial That Lets You Build Big!

Start building with 50+ products and up to 12 months usage for Elastic Compute Service

  • Sales Support

    1 on 1 presale consultation

  • After-Sales Support

    24/7 Technical Support 6 Free Tickets per Quarter Faster Response

  • Alibaba Cloud offers highly flexible support services tailored to meet your exact needs.