Prepstellar

DP-700 · Workspace Lifecycle Management

33 cards

Warehouse Database Projects

Swipe, scroll or use ← →
  1. See what a warehouse database project is

    A Fabric warehouse has a schema: tables, views, stored procedures, and functions. A database project keeps that schema as files on your machine, one .sql file per object, so that you can edit it in an editor, validate it before it reaches the warehouse, and deploy it in a controlled way.

    For Fabric Data Warehouse, the project is developed in Visual Studio Code. The work has four steps: create the project, define the schema objects, build and validate the project, and publish it to the warehouse. This feature is in preview.

    Behind the extension works DacFx, the Data-Tier Application Framework. The SQL Database Projects extension uses the DacFx package to build and publish database projects, compare schemas, script changes, and extract or deploy .dacpac files. A .dacpac file is the compiled model of the warehouse schema.

    The SQL database lesson showed a project that Fabric generates for you inside Git. Here you own the project and you run the build and the publish yourself.

    1 / 33
  2. Quick check

    What does a database project for Fabric Data Warehouse hold?

    1. AThe rows of the warehouse tables, exported as files

      A project describes the schema. Table rows are not part of it, and a publish changes the schema of the target to match the project.

    2. BThe schema objects of the warehouse, as T-SQL definition files

      Right. Tables, views, stored procedures, and functions are kept as .sql files that you build into a dacpac and publish.

    3. CThe reports and semantic models built on the warehouse

      Reports and semantic models are other Fabric items. The project only holds the definitions of warehouse objects.

    2 / 33

  3. Prepare the tools and the access

    Four things must be in place before you create a project.

    Requirement Detail
    Access to a warehouse An existing Warehouse item in a Fabric workspace, with Contributor or higher permissions
    Visual Studio Code Installed on your workstation
    .NET SDK Needed to build and publish database projects
    Two extensions SQL Database Projects and SQL Server (mssql)

    Each piece has a job. The SQL Server (mssql) extension holds the connection to the warehouse. The SQL Database Projects extension creates, builds, and publishes the project. The .NET SDK is what builds and publishes database projects.

    The role is the one to remember: Contributor is the lowest workspace role that works. Member and Admin also qualify. The Viewer role sits below Contributor and does not meet the requirement.

    3 / 33
  4. Quick check

    A developer has Visual Studio Code with the SQL Database Projects and SQL Server (mssql) extensions, and is a Contributor in the workspace. The project cannot be built. What is most likely missing?

    1. AThe Admin role in that workspace

      Contributor or higher is enough, so the role is not the problem here.

    2. BA Git connection for the workspace

      Building a project is local work in Visual Studio Code. It does not need the workspace to be connected to Git.

    3. CThe .NET SDK on the workstation

      Right. The .NET SDK is required to build and publish database projects, and it is the one prerequisite the developer does not have.

    4 / 33

  5. Create the project

    You can create a database project from scratch or from an existing warehouse.

    From scratch, start from the Command Palette with Database Projects: New, or from the Database Projects pane with Create new. The answers are the same in both:

    1. Database project type: SQL Server Database.
    2. A project name and a local folder.
    3. Target platform: Synapse Data Warehouse in Microsoft Fabric.
    4. SDK-style project: Yes.

    Two of these answers are not preferences. The target platform must be Synapse Data Warehouse in Microsoft Fabric, even though the project type says SQL Server. And only SDK-style projects are supported for Fabric Data Warehouse.

    5 / 33
  6. Create the project

    To start from an existing warehouse, you first need a connection profile in the SQL Server extension.

    • Server name: in the Fabric portal, open the Settings of the warehouse, select SQL connection string, and copy the string. It is the server name of the warehouse, and it is different from the SQL analytics endpoint.
    • Authentication type: Microsoft Entra ID - Universal with MFA support.

    Then open the ... options of the Database Projects pane and select Create Project From Database. Choose the warehouse from the connection profiles, then a project name and a folder. Visual Studio Code extracts the project files from the warehouse.

    Question in the wizard Answer
    Folder structure Schema/Object Type (recommended)
    Include permissions in project No (default)
    SDK-style project Yes (recommended)

    The result is a project with a folder per schema and, inside it, folders such as Tables, Views, and Functions.

    6 / 33
  7. Quick check

    A team already has a warehouse with 40 tables and wants a database project that starts with those definitions. What should a developer do in Visual Studio Code?

    1. ACreate a connection profile, then use Create Project From Database

      Right. With a connection profile for the warehouse, Create Project From Database extracts the project files from it.

    2. BUse Database Projects: New, then Publish to pull the tables in

      Publish goes the other way: it changes the warehouse to match the project. Publishing an empty project does not bring definitions into it.

    3. CUse Database Projects: New with the SQL analytics endpoint as target

      A new project starts empty, and the server name of a warehouse is different from the SQL analytics endpoint.

    7 / 33

  8. Keep your progress in the app

    That’s 3 of 12 quick checks. In the app they stay answered, and every lesson remembers where you left off.

    Opens in your browser. Nothing to install.

    Start studying

    On your phone, with the same account

    Get it on Google Play Download on the App Store
    Keep reading here
  9. Configure the project file

    The project file has the extension .sqlproj. Right-click the project and select Edit .sqlproj File. Two things need checking.

    First, the SDK. The file should use the latest version of the Microsoft.Build.Sql SDK:

    <Sdk Name="Microsoft.Build.Sql" Version="2.3.0" />
    

    Second, the reference to the system objects of a Fabric warehouse. Add a package reference to Microsoft.SqlServer.Dacpacs.FabricDw inside the ItemGroup node:

    <PackageReference Include="Microsoft.SqlServer.Dacpacs.FabricDw" Version="170.0.4">
      <DatabaseVariableLiteralValue>master</DatabaseVariableLiteralValue>
      <SuppressMissingDependenciesErrors>False</SuppressMissingDependenciesErrors>
    </PackageReference>
    

    The first line names the package and its version. The second line, DatabaseVariableLiteralValue with the value master, is metadata on the reference. It looks optional and it is not, as you will see next. Save the file and select Yes when Visual Studio Code asks to reload the project.

    8 / 33
  10. Configure the project file

    The DatabaseVariableLiteralValue line is easy to leave out, and the result is confusing because the build still succeeds.

    The failure comes later. Without that metadata, Publish and Script actions can fail as soon as your code references objects in the sys schema, such as sys.views. The error looks like this:

    Error SQL72033: This deployment may encounter errors during execution because [<schema>].[<procedure>] depends on [sys].[views].[schema_id] and [sys].[views].[schema_id] does not exist in the target database.
    

    So the pattern to recognize is: build fine, publish fails, error SQL72033, and a sys object that supposedly does not exist. The fix is in the package reference, not in your procedure.

    One more habit: the version numbers above are examples. New versions of these NuGet packages are released often, so update the versions in your local project to stay aligned with the latest ones.

    9 / 33
  11. Quick check

    A developer adds the package reference to Microsoft.SqlServer.Dacpacs.FabricDw but leaves out the DatabaseVariableLiteralValue line. A stored procedure in the project reads sys.views. What should the developer expect?

    1. AThe build fails at once and names the missing line

      The build is not where the problem shows. It still succeeds, which is what makes this mistake hard to spot.

    2. BThe build succeeds, and Publish or Script can then fail

      Right. Without that metadata the build works, and Publish and Script actions can fail as soon as code references objects in the sys schema.

    3. CThe build and the publish both succeed, because the line is optional

      The line is needed in practice. Once code references sys objects, the publish can fail with error SQL72033.

    10 / 33

  12. Edit objects and build

    Under the folder of a schema, for example dbo, each object is a .sql file with its T-SQL definition. You add, delete, or change those files to define tables, views, stored procedures, and functions. To modify an existing object, open its file and update the definition.

    Then right-click the project and select Build. The build validates all new and updated objects and includes them in the generated dacpac file:

    {project folder location}/bin/debug/{project name}.dacpac
    

    If the build fails, the output of the build shows the errors to fix.

    Two details save time:

    • Changes are local until you publish. Changes made in the project are not reflected in Microsoft Fabric until you Build and Publish the project.
    • The terminal matters. Currently, the default terminal of Visual Studio Code must be PowerShell for the build in the Database Projects extension to succeed. You set it in the Command Palette with Terminal: Select Default Profile.
    11 / 33
  13. Quick check

    A developer adds a view file to the project and builds it successfully, but cannot find the view in the warehouse. Why?

    1. AThe project has been built, but it has not been published

      Right. A build validates the objects and produces the dacpac in bin/debug. The warehouse changes only when the project is published.

    2. BA build writes to the warehouse only for tables

      A build never writes to the warehouse, for any kind of object. It only produces the dacpac file.

    3. CThe default terminal was not PowerShell

      A wrong terminal makes the build fail. Here the build succeeded, so the missing step is the publish.

    12 / 33

  14. Publish to the warehouse

    Publishing is the step that changes the warehouse. It creates a script that resolves the difference between the database project and the actual warehouse, and it executes that script to make the warehouse match the project.

    Right-click the project and select Publish. Choose Publish to an existing SQL server, then the connection profile of the warehouse and the name of the target warehouse. For the publish profile, choose Don't use profile the first time. The last choice is the action.

    Action What it does
    Generate Script Produces the T-SQL that would be applied. It makes no changes to the target warehouse.
    Publish Writes the changes to the target warehouse.
    13 / 33
  15. Publish to the warehouse

    The first time you deploy changes, generate the script and review the T-SQL before you publish.

    At the end, Visual Studio Code asks whether you would like to save the settings in a profile. Choose Yes. A publish profile is a .publish.xml file that stores the options you used, so the next time you load the profile and do not answer the questions again.

    A project is not limited to one profile. You might have different profile options for different warehouses, or for the different environments of your development process, such as dev, test, acceptance, and production. The next section shows why: the safe options for production are not the convenient options for development.

    14 / 33
  16. Quick check

    A team publishes the same warehouse project to dev, test, and production, and each environment needs its own publish options. How should the team handle this?

    1. ACreate one project per environment, each with its own files

      The schema is the same in all three, so one project is enough. What differs is the set of publish options.

    2. BEdit the .sqlproj file before each publish

      The .sqlproj file describes the project and its references. The options of a publish are saved in a publish profile.

    3. CSave one publish profile per environment and load the right one

      Right. A publish profile is a .publish.xml file with the publish options, and a project can have different profiles for different environments.

    15 / 33

  17. Set the options that protect data

    Two publish settings decide whether a deployment may remove things. They are the part of this lesson most likely to cost you data.

    Setting What it does Where to use it
    BlockOnPossibleDataLoss Prevents the deployment if there is a risk of data loss, for example dropping a column or a table that contains data Always True in production
    DropObjectsNotInSource Drops objects in the target database that are not present in the project source Dev and test, to clean up leftover objects

    Read them as two different questions. BlockOnPossibleDataLoss asks: may this deployment lose data? With True, it stops. With False, the deployment is allowed even if data can be lost, so False is only for controlled environments such as dev or test.

    DropObjectsNotInSource asks: what happens to objects that exist in the warehouse and not in the project? With True, they are dropped. In production that can delete important objects and data, so double-check before you enable it there.

    16 / 33
  18. Set the options that protect data

    An example makes the difference concrete. The production warehouse holds a table dbo.AdHocFix that someone created by hand. It is not in the project.

    Profile Result for dbo.AdHocFix
    DropObjectsNotInSource False The table stays. The publish only changes what the project describes.
    DropObjectsNotInSource True, BlockOnPossibleDataLoss False The table is dropped, with its rows.

    In SqlPackage, the command-line tool that publishes dacpac files, BlockOnPossibleDataLoss defaults to True and DropObjectsNotInSource defaults to False. The defaults are the safe side, and a profile that changes them should be a decision, not an accident.

    17 / 33
  19. Quick check

    A dev warehouse is full of tables left over from experiments, and the team wants every publish to remove whatever is not in the project. Which setting does that?

    1. ABlockOnPossibleDataLoss set to False

      False only allows a deployment to continue when data can be lost. It does not make the publish look for objects outside the project.

    2. BDropObjectsNotInSource set to True

      Right. DropObjectsNotInSource drops objects in the target that are not present in the project source, which is its intended use in dev and test.

    3. CBlockOnPossibleDataLoss set to True

      True stops a deployment that could lose data. It protects objects and never removes them.

    18 / 33

  20. Run scripts before and after the deployment

    A publish compares schemas. Some work is not schema: copying rows away before a table disappears, or filling a lookup table. For that work a project has two script slots.

    Script When it runs Common uses
    PreDeploy Before the schema deployment Archive or back up data before dropping tables, disable constraints temporarily, clean up legacy objects
    PostDeploy After the schema deployment Seed lookup or reference data, re-enable constraints, log deployment history

    The order decides which slot you need. Data that the deployment is about to remove must be saved in PreDeploy, while the table still exists. Data that needs the new schema must be written in PostDeploy, when the new tables and columns are there.

    19 / 33
  21. Run scripts before and after the deployment

    Both scripts run on every publish, so both should be idempotent. An idempotent script can run multiple times without causing logical problems or failures, and it can be deployed to several databases without knowing their state in advance.

    In practice: a script that inserts five lookup rows is not idempotent, because the second run fails or duplicates them. A script that first checks which rows exist, or that deletes and reloads the five rows, gives the same result on every run.

    Three cautions complete the picture:

    • A PreDeploy script should not introduce schema changes that conflict with the deployment.
    • A PostDeploy script should avoid heavy operations on large tables in production.
    • The build does not check these scripts. Pre-deployment and post-deployment scripts are not validated against the database model at build time. An error in a script surfaces at deployment time, and a script failure halts the deployment.
    20 / 33
  22. Run scripts before and after the deployment

    The same two slots exist for a warehouse item inside Fabric, also in preview. There, a pre-deployment or post-deployment script is one of the shared queries under the Queries folder of the warehouse. You designate it in the Fabric portal, with Set deployment scripts in Object Explorer or in the CI/CD section of the warehouse Settings.

    Three rules come with that designation.

    • One of each. A warehouse supports at most one pre-deployment script and one post-deployment script, each in a single file. The same shared query cannot be both.
    • It is stored in the project file. On commit, the designation is written to the .sqlproj file as a PreDeploy or PostDeploy item. If the .sqlproj contains multiple pre-deployment or post-deployment entries, the Git update fails.
    • It runs on every deployment. On an update from Git, the pre-deployment script runs first, then the schema changes are applied, then the post-deployment script runs. Deployment pipelines also run the designated scripts in each target stage.
    <ItemGroup>
      <PreDeploy Include="pre-deployment.sql" />
      <PostDeploy Include="post-deployment.sql" />
    </ItemGroup>
    
    21 / 33
  23. Quick check

    A PostDeploy script contains a plain INSERT of three reference rows. The first publish works. What is the risk on the second publish?

    1. AThe script is skipped, because PostDeploy runs only once per warehouse

      The script runs after the schema deployment on every publish, which is why it has to be safe to repeat.

    2. BThe script runs before the schema change and finds no table

      PostDeploy runs after the schema deployment. The script that runs before it is PreDeploy.

    3. CThe script runs again and fails or duplicates the rows

      Right. The script is not idempotent. It must give the same result on every run, for example by checking which rows already exist.

    22 / 33

  24. Version the warehouse with Git integration

    Visual Studio Code is one way to keep a warehouse as code. Fabric Git integration is another, and for warehouses it is also in preview.

    When you connect a workspace with a warehouse to Git, the warehouse definition is committed as a database project. That project becomes the authoritative representation of the warehouse schema in source control, and in the repository the schema appears as individual .sql files.

    When the workspace is synchronized from Git, Fabric does not recreate the warehouse. It uses DacFx-based incremental schema deployment, which applies only the relevant schema differences instead of updating the entire warehouse definition. It is the same idea as a publish from Visual Studio Code: compare, then apply the difference.

    One file is left out on purpose. XMLA.json is excluded from commits and updates, so the default semantic model metadata is not stored in Git, and it is ignored when the workspace is synchronized from Git.

    23 / 33
  25. Quick check

    A workspace with a warehouse is updated from Git after a merge that changed two views. How does Fabric apply the change?

    1. AIt drops the warehouse and creates it again from the .sql files

      Nothing is recreated. Synchronization is incremental and only touches what differs.

    2. BIt deploys only the schema differences, with DacFx

      Right. Fabric uses DacFx-based incremental schema deployment, so only the relevant schema differences are applied to the warehouse.

    3. CIt replaces XMLA.json and rebuilds the semantic model

      XMLA.json is excluded from commits and updates and is ignored when the workspace is synchronized from Git.

    24 / 33

  26. Know the limits of warehouse Git integration

    Git integration for warehouses has limits that change how you design a release. The first group concerns what source control carries.

    Limit What it means for you
    SQL security Roles, users, and GRANT or DENY permissions are not included in the project, and neither is table data. Recreate them with a post-deployment script.
    Deployment scripts in Git They need the latest source control experience. In a workspace that has not been upgraded, deployment script metadata is not synchronized with source control.
    No selective commit Changes are committed at the warehouse item level, not object by object.
    SQL analytics endpoints Version control for SQL analytics endpoints is not available.
    25 / 33
  27. Know the limits of warehouse Git integration

    A post-deployment script for security runs on every deployment, so it tests before it creates:

    IF NOT EXISTS (SELECT 1 FROM sys.database_principals WHERE name = N'DataReaders')
    BEGIN
        CREATE ROLE DataReaders;
    END;
    GO
    GRANT SELECT ON SCHEMA::dbo TO DataReaders;
    GO
    

    The role is created only when it is missing, and then it receives SELECT on the dbo schema. Some earlier guidance says that scripts added to the project through Git are not preserved, so check which source control experience a workspace has.

    The third row surprises people. If you changed three views and one table in a warehouse, you cannot commit only the views. The warehouse is one item, and the commit takes all four changes.

    26 / 33
  28. Know the limits of warehouse Git integration

    The second group concerns operations that fail or are not supported.

    Situation Effect
    Two or more warehouse items reference each other (a cyclic dependency) Branch-out and Git-to-workspace sync fail
    A Dataflow Gen2 writes to the warehouse A new item named DataflowsStagingWarehouse appears in the repository and blocks committing and updating from Git
    The repository has a .sqlproj that pins an older Microsoft.Build.Sql SDK Committing or updating can fail, because the older SDK does not recognize newer syntax such as IDENTITY columns and CLUSTER BY
    Warehouses with different collations in a deployment pipeline, a branch-out, a branch switch, or a merge Not officially supported

    The first row is a design problem, not a setting. When two or more warehouse items reference each other, Fabric detects the circular reference during branch-out or a sync from Git to the workspace, and the operation fails. The fix is to avoid cyclic dependencies between items.

    The collation case is the dangerous one because it can look fine. These operations might succeed without errors and still result in metadata errors: in a deployment pipeline, for example, the deployment might succeed, but the dataset collation is not updated to match the collation of the target warehouse.

    27 / 33
  29. Quick check

    A deployment pipeline promotes a warehouse from Dev to a Prod warehouse that was created with a different collation, and the deployment reports success. What should the team conclude?

    1. ASuccess means that the pipeline converted the collation of Prod

      The collation metadata is not reconciled. Success of the operation does not mean the collations now match.

    2. BThe scenario is not supported, and metadata errors can still appear

      Right. With different collations the workflow is not officially supported: it might finish without errors and still leave metadata errors.

    3. CThe deployment was a selective commit that left the collation out

      Selective commit is a Git idea, and warehouses do not support it. It has nothing to do with collation in a pipeline.

    28 / 33

  30. Choose a route for development and deployment

    With all the pieces on the table, the remaining question is which route fits a team. Fabric Data Warehouse offers five modes, and they can be combined.

    Mode What it gives
    Fabric web, without Git Live development, no version control
    Fabric web, with Git Live development, version control, and workspace branching
    IDE or local development Visual Studio Code with DacFx for schema management and scripting, and SSMS for interactive development
    Fabric deployment pipelines Automated deployment, deployment tracking, and stage promotion
    External CI/CD Azure DevOps or GitHub, with DacFx tasks, the SqlPackage CLI, and REST APIs
    29 / 33
  31. Choose a route for development and deployment

    Read a scenario for its requirements and match each one to a mode.

    • One person, no history, no pre-production environments: Fabric web without Git. Without Git, changes are live and immediately reflected, and nothing tracks them.
    • History, review, and isolated work in the browser: Fabric web with Git. It adds commits, sync from Git, reverting to previous commits, and branching out to feature workspaces.
    • A local project with build, schema compare, and publish options: the IDE route, with a database project in Visual Studio Code.
    • Promotion from dev to test to prod, tracked inside Fabric: Fabric deployment pipelines.
    • Build and deployment automated in your own DevOps system: external CI/CD.

    The modes cover different needs, so a team can use two together: one to develop and version, and one to promote.

    30 / 33
  32. Quick check

    One analyst builds a warehouse alone for a short proof of concept. There is no team, no need for history, and no test or production environment. Which mode fits?

    1. AFabric web without Git integration

      Right. Live development without version control fits individual work with no collaboration, no version history, and no pre-production environments.

    2. BExternal CI/CD with the SqlPackage CLI

      External CI/CD automates build and deployment in Azure DevOps or GitHub, which is more than a one-person proof of concept needs.

    3. CFabric deployment pipelines with three stages

      Deployment pipelines promote content between stages, and this scenario has only one environment.

    31 / 33

  33. Key takeaways

    • Create it for the right target: the target platform is Synapse Data Warehouse in Microsoft Fabric, and only SDK-style projects are supported.
    • Contributor is enough: the warehouse must be in a workspace where you have Contributor or higher permissions.
    • Generate Script first: it shows the T-SQL and makes no changes to the target warehouse.
    • SQL72033 points to the package reference: add DatabaseVariableLiteralValue with the value master.
    • Two settings decide what a publish may remove: BlockOnPossibleDataLoss stays True in production, and DropObjectsNotInSource drops whatever is not in the project, so it belongs in dev and test.
    • Scripts must be idempotent: PreDeploy runs before the schema deployment and PostDeploy after it.
    • Git integration has limits: permissions need a post-deployment script, commits are at the warehouse item level, and warehouses that reference each other make branch-out fail.
    • Pick the route by requirement: Git in the Fabric web for versioning and isolated work, deployment pipelines for tracked stage promotion, external CI/CD for automation outside Fabric.
    32 / 33
  34. Quick check

    Which statement about warehouse database projects is correct?

    1. AA successful build applies the new objects to the target warehouse

      A build validates the objects and produces a dacpac. The warehouse changes only on publish.

    2. BDropObjectsNotInSource protects the objects that are missing from the project

      It does the opposite: it drops objects in the target that are not present in the project source.

    3. CGenerate Script shows the deployment T-SQL without changing the warehouse

      Right. Generating the script makes no changes to the target warehouse, which is why it is the first step of a first deployment.

    33 / 33

  35. 12 quick checks · then the test

    In the app, finishing the quick checks opens this lesson’s 10-question test, and the ones you miss come back exactly when you’re about to forget them.

    Take this lesson’s test → Next lesson: Create Deployment Pipelines

    Opens in your browser. Nothing to install.

    Start studying

    On your phone, with the same account

    Get it on Google Play Download on the App Store

The whole course, on your computer and your phone

Lessons you can read, audio you can listen to on the way to work, and practice that remembers what you got wrong.

Opens in your browser. Nothing to install.

Start studying

On your phone, with the same account

Get it on Google Play Download on the App Store

“This app is the ‘One Lake’ for preparing the certification exams. Really worth it.”

Abdelhak Y. Google Play review