Search code examples
sql-serverpowershelldacpac

Modify DacPac Using powershell


I need to read existing dacpac using powershell and change schema then replicate the database. Is there any possibility to use "System.Reflection"


Solution

  • There is a full public API that supports loading dacpacs, reading the contents (tables, views etc. in the schema), and adding / updating these contents before saving back. The samples project is at https://github.com/Microsoft/DACExtensions, with a tutorial explaining core concepts here. There are a number of additional examples, such as Ed Elliott's blog and open source contributions that can help you understand what to do.

    Disclosure: I work on the DacFx team and wrote the linked tutorial.