Does MS provide a way to query a SSDT project

ssdt

Is there a way to query a SSDT project to get a list of tables or foreign keys? Similar to what you can do with the actual database?

Best Answer

YES! You can query the output to an SSDT project called a dacpac using the DacFx.

The easiest way is to grab this sample project from microsoft (https://github.com/microsoft/DACExtensions/tree/master/DacFxStronglyTypedModel) and build the "DacExtensions" dll then reference that from your own code (c#, powershell etc.)

When you use the DacExtensions you can then you can ask for a list of tables or foreign keys, have a look at this:

https://stackoverflow.com/questions/40747082/finding-data-type-information-for-certain-objects-in-dacfx-api

The question shows how to get the TSQLModel and the answer has how to get a list of tables.

Good luck!