1
I created a database project for Azure SQL Database using visual Studio (SSDT). For now I have only two tables:
CREATE TABLE [dbo].[ServiceOrder]
(
[Id] INT NOT NULL IDENTITY,
[Name] VARCHAR(50) NOT NULL,
CONSTRAINT [PK_ServiceOrder] PRIMARY KEY ([Id])
)
and
CREATE TABLE [dbo].[QuestionsToServiceOrders]
(
[ServiceOrderId] INT NOT NULL ,
[Question] VARCHAR(100) NOT NULL,
CONSTRAINT [PK_QuestionsToServiceOrders] PRIMARY KEY ([Question], [ServiceOrderId]),
CONSTRAINT [FK_QuestionsToServiceOrders_ToServiceOrders] FOREIGN KEY ([ServiceOrderId]) REFERENCES [ServiceOrders]([Id])
)
The problem is I’m falling for the infamous mistake:
Error SQL71501: Foreign Key: [dbo]. [Fk_questionstoserviceorders_toserviceorders] has an unresolved Reference to Column [dbo]. [ServiceOrders]. [Id]. CloudEyeDatabase D:\ProgramStudio\CloudEye\CloudEyeWeb\FASE0.0.0.1\CoudEyeDatabase\QuestionsToServiceOrders.sql 6
I did some research on the net and discovered that it is a common mistake for those who create SQL Server database projects with Visual Studio. The problem is, from what I’ve seen, there are several possible solutions, I’ve tested a few but they haven’t worked. There are other possible solutions, but honestly I have not tested because I do not even know if they apply to my case, because my taget of the project is the Azure SQL Database
. Some solutions I honestly didn’t understand how that one for example.
Someone’s had that problem before?
If someone wants to try to reproduce the error just create a new project (VS2017) from SQL Server (Other Languages/SQL Server/SQL Server Database Project) and add two tables that I showed above.
I was going to delete this question because the error is very silly. But someone will go through the same situation. In FK reference the table name is plural
ServiceOrders
but the table is being created with the name in the singularServiceOrder
.– Matheus Saraiva