[英]How do I generate script for LocalDB database?
I'm using localdb for development with Visual Studio and SSDT. 我正在使用localdb进行Visual Studio和SSDT的开发。 I want to export the database schema and import it in full-fledged SQL Server instance.
我想导出数据库模式并将其导入完整的SQL Server实例。 How do I do that?
我怎么做?
I don't have (or want to install) SSMS. 我没有(或想要安装)SSMS。 Can this be done with Visual Studio/SSDT only?
这可以仅使用Visual Studio / SSDT吗?
In SSDT, just do a schema compare against a blank database and it will build a change script for you. 在SSDT中,只需对空白数据库进行模式比较,它将为您构建更改脚本。
https://msdn.microsoft.com/en-us/library/hh272690(v=vs.103).aspx https://msdn.microsoft.com/en-us/library/hh272690(v=vs.103).aspx
I'll summarize the answers and give a bit more suggestions. 我将总结答案并提出更多建议。
Use schema compare 使用架构比较
As @Nick.McDermaid mentioned you can use schema compare to generate the script. 正如@ Nick.McDermaid所提到的,您可以使用模式比较来生成脚本。 However if you use variables it might not work as you expected.
但是,如果使用变量,它可能无法按预期工作。 Moreover pre/post scripts will not be included to the output script
此外,前/后脚本不会包含在输出脚本中
Use SSDT Publish 使用SSDT发布
Right-click on the project and choose Publish. 右键单击该项目,然后选择“发布”。 There setup the connection and you will have 2 options.
设置连接,您将有2个选项。
Choose the one you need 选择你需要的那个
Dacpac Dacpac
You can build the project and find the project_name.dacpac file in the bin folder. 您可以构建项目并在bin文件夹中找到project_name.dacpac文件。 Then you can use SqlPackage to deploy your changes ( HOWTO )
然后您可以使用SqlPackage来部署您的更改( HOWTO )
只需将SSDT项目发布到另一个SQL Server实例/版本即可
声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.