簡體   English   中英

CS0246 C#找不到類型或名稱空間名稱“ ForeignKeyAttribute”(是否缺少using指令或程序集引用?)

[英]CS0246 C# The type or namespace name 'ForeignKeyAttribute' could not be found (are you missing a using directive or an assembly reference?)

我正在學習使用Entity Framework Code First通過Azure移動應用服務創建數據庫

但我有一個錯誤,看起來像

在此處輸入圖片說明

CS0246 C# The type or namespace name 'ForeignKeyAttribute' 
could not be found (are you missing a using directive or an assembly reference?)

而且我已經使用過System.ComponentModel.DataAnnotations.Schema; 但似乎不起作用。

我該如何解決?

================================================== ===

最后,我解決了這個問題! 為什么我不能引用System.ComponentModel.DataAnnotations?

System.ComponentModel.DataAnnotations是ForeignKey和Required的命名空間。

System.ComponentModel.DataAnnotations.Schema更具體。 例如,如果您想將字段映射到特定的列名或將實體映射到表名。

暫無
暫無

聲明:本站的技術帖子網頁,遵循CC BY-SA 4.0協議,如果您需要轉載,請注明本站網址或者原文地址。任何問題請咨詢:yoyou2525@163.com.

 
粵ICP備18138465號  © 2020-2024 STACKOOM.COM