Questions tagged [database-project]
Visual Studio Database Projects allow developers to create, manage, update, and deploy databases with the same development tools and processes as any other source code project.
630
questions
0
votes
1
answer
37
views
Visual Studio 2022 cannot publish an Azure SQL database project
I have created a DB project with VS2022 for an Azure SQL DB and everything works perfectly under my own credentials. I have also created a login (jdoe), a user (jdoe) under that login and I have given ...
0
votes
1
answer
55
views
SQL Database Projects (VS Code) Unit Tests Migration
I have inherited an SSDT project that I am in the process of migrating over to the newer SQL Database project in VS Code (.NET Core).
The aim is to create a Linux-based CI/CD pipeline in Azure DevOps.
...
0
votes
0
answers
19
views
Azure DevOps SHA Database Build fails w Error MSB4061 SqlModelResolutionTask could not be instantiated from Microsoft.Data.Tools.Schema.Tasks.Sql.dll
My yaml file
trigger:
- main
steps:
- task: VSBuild@1
displayName: 'VS Build on the Solution'
inputs:
solution: 'My.Database.sln'
vsVersion: '17.0'
platform: 'any cpu'
...
1
vote
0
answers
143
views
"Drop objects not in source" not honored
I'm attempting to use Schema Compare in SQL Server Data Tools to update my project from a database. I deselected "Drop objects not in source" setting but SSDT continues to drop objects that ...
0
votes
1
answer
54
views
Visual Studio Database Project MATERIALIZED VIEW Error SQL71640: COUNT_BIG(a) is required when using this tool to create a materialized view
I can't find a solution to this one.
I have COUNT_BIG() in the script and I got the "SQL71640: COUNT_BIG(a) is required" error. But when I changed my script to COUNT_BIG(1), the error will ...
1
vote
0
answers
90
views
Azure Data Studio, Database Project, Postdeployment scripts
I am trying to get multiple files into a post-deployment
using project Azure Data Studio
I have a main deployment file Script.PostDeployment_Main.sql
Contents
are
-- This file contains SQL statements ...
0
votes
1
answer
78
views
How do I change the filepath using Visual Studio Database Project?
declare @databasename varchar(50) = 'aDatabase'
declare @dbNameTimeStamp varchar(100) = 'aDatabase_20230404_0916'
declare @backupFilePathForDev varchar(max) = 'N''J:\Program Files\Microsoft SQL ...
1
vote
0
answers
39
views
handle CREATE LOGIN x WITH PASSWORD in database projects
How to manage logins with password in database project in visual studio? Again I compare the database schemas and the same problem occurs - either the passwords are copied to the code repository from ...
0
votes
0
answers
75
views
Issue importing database to database project in Visual Studio
I have created a dev database in SQL Server and added a table in SSMS. I have created a .NET 6 application and created the database project and data project and now I am trying to import the database.
...
1
vote
1
answer
81
views
Create roll-on script using Database Project that does not require SqlCmd
When using database projects, compare, and then Generate Script then the generated scripts is default for SqlCmd. E.g. it generates a row like:
/*
Detect SQLCMD mode and disable script execution if ...
0
votes
0
answers
131
views
Azure Data Studio unresolved references in referenced object not suppressed
Using Azure Data Studio, I have created a project from an existing SQL Server database - [Main_project]
Some views in that database reference objects in another database.
I have created a separate ...
1
vote
0
answers
36
views
Referencing a .NET Standard project from a SQL Database project causes Visual Studio to hang opening the solution
We're developing a SQL Database project in Visual Studio 2022 that will be loaded into SQL Server 2017 as a CLR assembly. In the same Visual Studio solution we have a .NET Core 3.1 class library ...
0
votes
1
answer
357
views
VS2022 Database Project Reference Keep Breaking
Vs2022, I have a database project. Within that project are some views and functions which refer to a system database. So I have added those system database references, both Master and MSDB to the ...
0
votes
0
answers
95
views
Make roll-off script using Visual Studio 2022 Database Project
I have a Visual Studio 2022 database project.
Here it is super easy to compare to a database and create a roll-on script.
But when when I switch the compare view around so my source is my database and ...
0
votes
1
answer
249
views
Add Primary Key Constraint keeps appearing in schema compare but won't commit to the database project
I am working on a database project in azure data studio. I added a primary key constraint to an existing table. When I update the project from the database, the schema compare picks up on the change.
+...
0
votes
0
answers
415
views
How to make schema changes while preserving data when using database project in visual studio?
Last year we had imported the database into a visual studio database project.
Subsequent db schema changes (like changing of data type, adding new tables, columns) were made offline in the visual ...
0
votes
1
answer
73
views
SQL CMD :setvar from file
I am using a PostDeploy script in a SQL Server project in Visual Studio.
Is there a way I could read the content of a file (JSON) from the project as a variable into this script?
I know I can use :r ...
1
vote
2
answers
445
views
Visual Studio Database Project removing user after every Publish?
I have a Visual Studio database project, every time I publish it to SQL Server, it removes the NT AUTHORITY\NETWORK SERVICE Login user.
After every publish I then have to go back into SQL Server ...
0
votes
1
answer
89
views
How to avoid dropping schemas when publishing DB in VS 2019 Database project
When publishing a database from Visual Studio, there are several options to "do not drop" an object if it is not in the Source. However, it seems that there is no option to avoid dropping ...
0
votes
1
answer
281
views
Is there a way to import ANSI_NULLS ON/OFF for stored procedures in VS database projects?
We have around 1000 stored procedures with few having SET ANSI_NULLS ON and some OFF, depending on the scope.
Using VS2019 and importing all procedures into a new project, the ANSI setting is not ...
0
votes
1
answer
1k
views
Database project won't drop table on publish via Visual Studio
I have a database project opened in visual studio 2022. I create a new table and when I execute my publish profile I can see in SSMS it has added the new table.
I now try to delete the table within ...
2
votes
1
answer
577
views
Handling SQL Login/Passwords when deploying a VS Database Project (DACPAC)
After an initial publish to a SQL Server(2019) and after the initial create of my DB project (data tier app) when publishing again it is failing with a drift report. No changes done to the database ...
2
votes
1
answer
482
views
Difference between publish and schema compare
I'm setting up database projects in Visual Studio for our existing databases and I wonder what the difference is between Schema Compare and Publish. For me Publish is a familiar term from using Visual ...
4
votes
1
answer
3k
views
Is it literally impossible to build a SQL Server database project in Azure Data Studio on an M1 Mac?
I'm attempting to set myself up with Azure Data Studio on my new M1 Mac Mini, but the SQL Server database project I'm working on refuses to build. This is the (completely useless) error I'm getting:
...
0
votes
1
answer
242
views
Is Visual Studio necessary for SQL database DevOps CI-CD pipeline?
I am new to DevOps and trying to create CI-CD pipeline for SQL database. In development environment, we use SSMS but when searching the tutorial for CI-CD, everyone is using Visual Studio to create a ...
1
vote
0
answers
250
views
publishing multiple database projects from visual studio
We have a VS solution that has around 11 database projects, when pulling updated from our solution control I want to publish the databases to my local sql server, so that it reflects any changes since ...
0
votes
0
answers
427
views
Visual Studio Database Project SQLCMD Variable Undefined For View Definition
I'm using Visual Studio 2019 to create a database project with two databases that target SQL 2012. For this question I'll call the two databases 'DatabaseOne' and 'DatabaseTwo'. In 'DatabaseTwo', I ...
0
votes
0
answers
191
views
How to change column type while preserving data in .net database project?
I have this table
CREATE TABLE [dbo].[GameDetails]
(
[GameId] INT NOT NULL IDENTITY(1,1),
[Minutes] INT NULL,
CONSTRAINT [PK_GameDetails] PRIMARY KEY CLUSTERED (GameId)
) WITH (...
1
vote
0
answers
479
views
Update To Target Schema Compare Visual Studio Just Hangs
In Visual Studio 2019, when I update the visual studio project form the schema compare tool it just hangs. Its not like its a lot of objects being updated either. I tried googling the issue and most ...
1
vote
1
answer
212
views
Very odd C# sql db decimal issue
So i'm seeing some very odd behaviour that i can't work out what's going wrong and hoping someone can help. Originally i was seeing this in a bigger application with lots of values, but i've stripped ...
-1
votes
1
answer
30
views
Assign diffrent sql scripts for diffrent publish files
I got my database projects and diffrent publish files which targets diffrent databases. Currently i see there could be only one sql marked as PostDeploy which simply means this script will be executed ...
0
votes
1
answer
2k
views
Visual Studio 2019 Database Project, How to Refresh/Regenerate
I have Visual studio 2019 database Project which has gone out of sync, because of direct updates on the DB.
How do I refresh my visual Studio 2019 Database Project from Source Database ? Did not any ...
1
vote
1
answer
344
views
Microsoft Database Project - How to change column type and avoid data loss error
I am trying to change the type of a column from VARCHAR to INT.
During the deployment, the database project will stop the deployment due to the "data loss" error:
RAISERROR (N'Rows were ...
1
vote
1
answer
165
views
SSDT Changing Scoped Credentials for different environments
I am looking to use continuous integration to deploy my SSDT project to a UAT and production environments and use external tables which point to azure data lake. The following statements need to be ...
0
votes
1
answer
172
views
SSDT update schema when data exists
I have an SQL server DB project with some table structure, for example:
tblUser
Id
Name
CustomerTypeId
This is the production database and it contains a lot of data.
Next, I need to add a new table
...
4
votes
1
answer
2k
views
SQL Server database project gives warning 'Unresolved reference to object sp_executesql'
SQL Server database project gives warning 'Unresolved reference to object sp_executesql' when using sp_executesql inside a stored procedure.
5
votes
0
answers
655
views
VSTS Error: SQLSQL71501: Computed Column: contains an unresolved reference to an object
I get the following error when building out my databaseB in my project. This database is referencing master, msdb as well as the other databases: databaseA and databaseAsynonyms.
databaseB uses ...
1
vote
1
answer
779
views
Getting error while executing DACPAC file (using sqlpackage.exe)
I am getting below error while executing DACPAC file using SQLPackage.
The column [dbo].[Temp].[GMTOffset] on table [dbo].[Temp] must be added, but the column has no default value and does not allow ...
2
votes
1
answer
1k
views
How do I create system versioned tables using SSDT in Visual Studio 2019?
I'm trying to create Table with system versioning using Database Project.
Following schema gives error:
SQL70633: System-versioned temporal table must have history table name explicitly provided.
...
1
vote
1
answer
564
views
Nested references between database projects in SSDT cannot be resolved
I'm currently creating a huge database solution with over 40 projects and tons of references.
It's a very common situation that project A references project B, then project B references project C and ...
1
vote
0
answers
269
views
SSDT Post Deployment & Always Encrypted
Struggling with an issue in SSDT when deploying seed data to a table that has AlwaysEncrypted Enabled.
SQL Server 2019 Enterprise
Windows Server 2016 Data Center
Visual Studio 2019 Community Edition ...
0
votes
1
answer
62
views
Does deploying a databse project affect other databases on a database servers?
I have a database for which I created a database project using visual studios.
I have created an Azure Repo and built it using Azure Build Pipelines.
I want to create a release pipeline for the same ...
1
vote
0
answers
76
views
Visual Studio Database Project Ignoring Comments
I am working with Visual Studio 2019. And I am using VS 2019 Database project for generating the "Dacpac" file for db deployment.
My problem is that when I am deploying the .dacpac file ...
0
votes
1
answer
309
views
Execute many scripts only if condition is met, without breaking IF through GO-statement
In my SSDT Project (Visual Studio Database Project) i have a lot of scripts that must be executed only if a condition is met.
The condition is the servername (@@servername != 'LiveServer').
The ...
0
votes
0
answers
439
views
SSDT/Visual Studio Database Project publishing DACPAC referenced DML table trigger SQL71501
I'm unable to publish SQL DML triggers inside of a VS Database/SSDT project. Everything else seems to publish updates/creations fine. However, my triggers aren't ever generated in the script. I can ...
1
vote
2
answers
773
views
Create SSDT objects (stored procedures etc.) only if a condition is met
I am reworking an existing database to work with SSDT for version control and easier deployment after something changed.
For this i need to create stored procedures that only get created when another ...
0
votes
2
answers
167
views
Is it possible to use variables with the 'DIALOG' and 'CONVERSATION' commands?
I've been able to setup my Visual Studio (2019) Database Project up and using database references fine for tables, stored procedures, views, etc. They all seem to match up fine with the schema I've ...
0
votes
4
answers
2k
views
SSDT has an unresolved reference to object for views but works fine for procedure
This error is not the "normal error", when there is a missing database reference. I have a database reference added correctly, and it worked fine so far with stored procedures.
The problem:
I have a ...
0
votes
0
answers
1k
views
OPTIMIZE_FOR_SEQUENTIAL_KEY breaks VS2019 database project build
I need to set OPTIMIZE_FOR_SEQUENTIAL_KEY = ON for several of my PKs on tables in Azure SQL Databases.
Running the code in SSMS against Azure SQL works perfectly, as expected. But, when I add the ...
1
vote
1
answer
3k
views
Visual Studio 2019 Database Schema Compare ignores foreign key names
This is all related to SQL Server.
Visual Studio 2019 Database Schema Compare ignores foreign key names (definition of the keys is the same) when comparing schema between Database Project (source) ...