0
我有下面的代碼我在哪裏上的ASp.net MVC應用程序無效列名Practice_PK
public class Element
{
/// <summary>
/// Primary Key
/// </summary>
[Key]
public int Pk { get; set; }
[ForeignKey("Practice_PK")]
[Display(Name = "Practices")]
public Practice Practice { get; set; }
[Display(Name = "Practices")]
public int Practice_PK { get; set; }
}
Database
CREATE TABLE [dbo].[Elements] (
[Pk] INT IDENTITY (1, 1) NOT NULL,
[Practice_PK] INT NULL,
CONSTRAINT [FK_dbo.Elements_dbo.Practices_Practice_PK] FOREIGN KEY ([Practice_PK]) REFERENCES [dbo].[Practices] ([PK]) ON DELETE CASCADE
);
GO
CREATE NONCLUSTERED INDEX [IX_Practice_PK]
ON [dbo].[Elements]([Practice_PK] ASC);
我收到錯誤「無效列名Practice_PK」每次我工作嘗試創建,編輯頁面。我知道這已被多次解決,但錯誤本身是如此模糊,我不知道如何解決。