How to create an instance of a local database using SMO

I installed localdatabase and created a shared instance, and using smo, I can create a local database.

For my requirement, I need to create a shared localdb instance.

I am creating a local database using SMO like this.

ServerConnection serConn = new ServerConnection(@"(localdb)\.\sharedIns"); Server ldbServer = new Server(serConn); Database db = new Database(ldbServer , "databaseName"); db.Create(); 

Before creating the database, I create a shared instance through the command line using sqllocaldb.exe, like this

 c:\>sqllocaldb create testIns c:\>sqllocaldb share testIn sharedIns 

I want to remove these steps manually and create a shared localdb instance using SMO. How to do it?

+3
source share
1 answer

I support the open source .NET library, which wraps the core native LocalDB API by providing an interface that allows you to do such things. See the links below for more details:

+2
source

Source: https://habr.com/ru/post/1500734/


All Articles