SSDT Error SQL71561 reference not resolved

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 that I'm falling into the notorious error:

  

SQL71501: Foreign Key Error:   [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 net-out research and found that it is a common mistake for anyone creating SQL Server database projects with Visual Studio. The problem is that from what I saw, there are several possible solutions, I tested some but they did not work. There are other possible solutions, but I honestly did not test it either because I do not know if they apply to my case, because my project tag is Azure SQL Database . Some solutions I honestly did not understand as this for example.

Has anyone ever had this problem?

If you want 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.

    
asked by anonymous 21.08.2018 / 01:49

0 answers