Giter Club home page Giter Club logo

ssdtdeployer's Introduction

SSDTDeployer

A simple lib reference Microsoft.Sqlserver.Dacpac and Microsoft.Sqlserver.SMO to handle Dacpac deploy and clean up to sql server instance or LocalDB, especially useful for unit testing

Get Started

  • Search for SSDTDeployer in nuget package manager.
  • Create an instance of SSDTDeployer.SsdtServerDeployer to handle sql server instance
  • Or create an instance of SSDTDeployer.SsdtLocalDbDeployer to handle LocalDB
  • Call methods "DeployDacPac", "DetachDb", "DeleteDb", "CreateDb"
  • All good!

Example code

var deployer = new SsdtLocalDbDeployer(dbName + ".mdf", true); //true: create if not exists
deployer.DeployDacPac(Utils.Dacpac);
var dbName = "TestDeployerLocalSqlInstance";
var connectString = String.Format(Utils.LocalInstanceConnectionString, dbName);
var deployer = new SsdtServerDeployer(connectString, dbName, true);
deployer.DeployDacPac(Utils.Dacpac);

Remarks

  • When doing unit testing with it, we'd better put the creation of databases in the initialization method and put the removing/clean up in the clean-up method,
  • keep in mind that not to force the testing to stop but let it go through even if it's broken by an exception, which allows the clean-up method to get the db server instance cleared

Known issues:

  • "Unable to cast object of type 'System.DBNull' to type 'System.String'." exception when trying to create instance of SsdtLocalDbDeployer
  • Cause: the deployer failed to create FileGroup "Primary" for the db, maybe due to previous uncleared enviroment
  • Workaround. use management studio to connect to (localdb)\V11.0 to manually remove the db (identified by file path), it will probably give another error while doing the removal, but it will do the job.
  • Solution: working on it...

ssdtdeployer's People

Contributors

jishun avatar

Stargazers

 avatar  avatar  avatar  avatar  avatar

Watchers

 avatar  avatar  avatar  avatar  avatar

Forkers

modulexcite

ssdtdeployer's Issues

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    ๐Ÿ–– Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. ๐Ÿ“Š๐Ÿ“ˆ๐ŸŽ‰

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google โค๏ธ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.