mercredi 17 avril 2019

SQL71501 :: Foreign Key: [dbo].[FK_AddressBook_Country] has an unresolved reference to Column [dbo].[AddressBook].[CountryID]

hope someone can help me. I have an error " SQL71501 :: Foreign Key: [dbo].[FK_AddressBook_Country] has an unresolved reference to Column [dbo].[AddressBook].[CountryID]. " It red line the ([CountryID)]. I can't find where its fault. I actually followed this site http://demo.dotnetawesome.com/mvc/mycontactbook/part2 , I just changed the tables. Hopefully, someone can help me with this. Thank you so much!

CREATE TABLE [dbo].[AddressBook] (
    [Id]           INT           NOT NULL,
    [Name]         VARCHAR (50)  NOT NULL,
    [Surname]      VARCHAR (50)  NOT NULL,
    [Address1]     VARCHAR (200) NOT NULL,
    [Address2]     VARCHAR (100) NULL,
    [Postcode]     VARCHAR (6)   NOT NULL,
    [Town]         VARCHAR (20)  NOT NULL,
    [Country]      VARCHAR (50)  NOT NULL,
    [Email]        VARCHAR (50)  NOT NULL,
    [MobileNumber] VARCHAR (20)  NOT NULL,
    [PictureUser]  VARCHAR (200) NULL,
    PRIMARY KEY CLUSTERED ([Id] ASC), 
    CONSTRAINT [FK_AddressBook_Country] FOREIGN KEY ([CountryID]) REFERENCES [Country]([CountryID])
);

CREATE TABLE [dbo].[Country] (
    [CountryID]   INT IDENTITY (1, 1) NOT NULL,
    [CountryName] VARCHAR (100) NOT NULL,
    PRIMARY KEY CLUSTERED ([CountryID] ASC)
);




Aucun commentaire:

Enregistrer un commentaire