0
votes

.NET database deployment solution where we are creating and upgrading our databases using DACPACS (using DacPackage, DacDeployOptions, DacServices classes).

The default schema is set as dbo in the SQL project properties, so all the database objects are now created in the dbo schema.

Requirement: I need an implementation to create/upgrade stored procedures and functions with different schema only. Ignore rest of the objects (tables, views, triggers etc) in the database.

Please suggest: how can I create/upgrade objects with different schema other than dbo in this case?

1
I found this link helpful to modify and update the DACPAC file. codeproject.com/Articles/1080452/… - Dileep Namburu

1 Answers

0
votes

In your sqlproj create the schema, do this my adding your new schema to the project create file SchemaB.sql with

CREATE SCHEMA [SchemaB]

Then prefix the object names, with the schema

CREATE TABLE [SchemaB].[Address]
(
    [Id] INT NOT NULL PRIMARY KEY,
    [Street] NVARCHAR(50) NOT NULL,
)

In the deployment option you can set that you only want to deploy specific types of objects, these options are stored in the publish file with your project, use this as input to the SqlPackage.exe command when deploying.