Yeoman generator-sqlproj
Say yo sqlproj and start developing mssql database.
This project requires Windows OS to build and publish a database because the build and publish tasks depend on Data-tier Application Framework (DacFx). It is available on Windows only.
Getting Started
First, install Yeoman and generator-sqlproj using npm (we assume you have pre-installed node.js).
npm install -g yo
npm install -g generator-sqlproj
Create a new folder for your database project and run yo sqlproj.
mkdir c:\mydatabase
cd c:\mydatabase
yo sqlproj
To import an existing database to the project, install mssql-scripter
pip install mssql-scripter
Then, open ./utils/importdb.ps1 and edit the server, database name to your -S server and -d database. If you are using SQL Login, add -u username and -P password for the connection. Then run it.
powershell ./utils/importdb.ps1
To build and publish the database project to mssql,
- install Visual Studio 2017 inlcuding Data Storage and Process Workload
- or install Build Tools for Visual Studio 2017 and DacFx (Data-tier Application Framework)
Build
powershell ./utils/build.ps1
Publish
powershell ./utils/publish.ps1
To change the publish target server and database, edit ./publish_profiles/localdev.publish.xml file.
<TargetConnectionString>Data Source=localhost;Integrated Security=True;Connect Timeout=60;Encrypt=False;TrustServerCertificate=True</TargetConnectionString>