简体   繁体   English

如何在 C# 中以编程方式创建 SQL Server 数据库 - 为每个项目创建新 SQL Server 数据库的项目管理应用程序

[英]How to create SQL Server database programmatically in C# - Project management application that creates a new SQL Server database for each project

Looking for the best approach to accomplish the following please:请寻找完成以下任务的最佳方法:

I am building an application that runs on two databases, a common 'library' database for common products, and a 'project' database.我正在构建一个在两个数据库上运行的应用程序,一个用于常见产品的公共“库”数据库和一个“项目”数据库。 Comparably in MS Access, you have an database template file that includes the library tables, and for each new project you simply copy and rename the database .mdb file and start to build your project.与 MS Access 相比,您有一个包含库表的数据库模板文件,对于每个新项目,您只需复制并重命名数据库.mdb文件并开始构建您的项目。

I want something similar for my application, where on startup, the user selects an existing project or a new project and is able to either open an existing database, or create a new database.我的应用程序需要类似的东西,在启动时,用户选择现有项目或新项目,并且能够打开现有数据库或创建新数据库。 I have accomplished this with SQLite as these are just files that can be copied and renamed, but I'm not sure how to go about this with SQL Server.我已经用 SQLite 实现了这一点,因为这些只是可以复制和重命名的文件,但我不知道如何用 SQL Server 解决这个问题。

Reason for separate library database is to be able to update the common library without having to update each project.单独库数据库的原因是能够更新公共库而不必更新每个项目。 Eventually I'd like to have this as a cloud/web application.最终我想把它作为一个云/网络应用程序。

Thanks in advance!提前致谢!

Try this尝试这个

 var server = new Server();
 var db = new Database(server, "db");
 db.Create();
    

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM