Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

How to create LocalDB instance programmatically? [duplicate]

Tags:

c#

.net

localdb

What is the .NET code equivalent of running below command?

sqllocaldb c <myInstance>

Please note that my question is NOT about creating a localdb database programmatically; rather creating an instance programmatically. I am trying to find about creating a new instance so that I can use (localdb)\myInstance in my connection string.

Update This is part of installing a desktop product. Creation of instance needs to happen on client machines that install this desktop product. As such, creating it using Visual Studio or SSMS is not the solution I'm looking for.

The closest answer I've gotten is @vasily.sib's Process.Start(). If no other option, this is what I will have to go with.

like image 636
ChaoticCoder Avatar asked Oct 31 '25 03:10

ChaoticCoder


1 Answers

I used sqllocaldb package from https://github.com/martincostello/sqllocaldb. It works beautifully for programmatically doing all local db operations.

like image 87
ChaoticCoder Avatar answered Nov 02 '25 18:11

ChaoticCoder