How to create local database Instance using SMO

余生颓废 提交于 2019-12-10 21:27:56

问题


I have installed localdatabase and created a shared instance, and using smo I am able to create localdatabase.

For my requirement I have to create a localdb shared instance.

I am creating 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 database, I am creating shared instance through command prompt using sqllocaldb.exe like this

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

I want to remove these manual steps and create localdb shared instance using SMO. How to do this?


回答1:


I maintain an open-source .NET library that wraps the underlying LocalDB native API, exposing an interface that allows you do this this kind of thing. See the below links for more detail:

  • SQL LocalDB Wrapper on GitHub
  • SQL LocalDB Wrapper on NuGet


来源:https://stackoverflow.com/questions/17407474/how-to-create-local-database-instance-using-smo

易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!