简体   繁体   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?)

I am learning using Entity Framework Code First to create my database via Azure Mobile App Service 我正在学习使用Entity Framework Code First通过Azure移动应用服务创建数据库

But I got an error , it looks like 但我有一个错误,看起来像

在此处输入图片说明

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

And I've already used System.ComponentModel.DataAnnotations.Schema; 而且我已经使用过System.ComponentModel.DataAnnotations.Schema; but it seems not to work . 但似乎不起作用。

How can I solve this ? 我该如何解决?

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

Finally , I solved it referring to this !! 最后,我解决了这个问题! Why can't I reference System.ComponentModel.DataAnnotations? 为什么我不能引用System.ComponentModel.DataAnnotations?

System.ComponentModel.DataAnnotations is the namespace for ForeignKey as well as Required. System.ComponentModel.DataAnnotations是ForeignKey和Required的命名空间。

System.ComponentModel.DataAnnotations.Schema is more specific. System.ComponentModel.DataAnnotations.Schema更具体。 For example, if you want to map a field to a specific column name or an entity to a table name. 例如,如果您想将字段映射到特定的列名或将实体映射到表名。

暂无
暂无

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

相关问题 C# 错误:错误 CS0246 找不到类型或命名空间名称“”(您是否缺少 using 指令或程序集引用?) - C# Error: Error CS0246 The type or namespace name '' could not be found (are you missing a using directive or an assembly reference?) C# 错误 CS0246 找不到类型或命名空间名称“Socket”(您是否缺少 using 指令或程序集引用) - C# error CS0246 The type or namespace name 'Socket' could not be found (are you missing a using directive or an assembly reference) CS0246:找不到类型或名称空间名称“ T”。 您是否缺少using指令或程序集引用? 在C#中 - CS0246: The type or namespace name `T' could not be found. Are you missing a using directive or an assembly reference? in c# 错误 CS0246:找不到类型或命名空间名称“IWebHostEnvironment”(您是否缺少 using 指令或程序集引用?) - error CS0246: The type or namespace name 'IWebHostEnvironment' could not be found (are you missing a using directive or an assembly reference?) CS0246:找不到类型或名称空间名称“ Employee”(您是否缺少using指令或程序集引用?)? - CS0246: The type or namespace name 'Employee' could not be found (are you missing a using directive or an assembly reference?)? CS0246 找不到类型或命名空间名称“ErrorViewModel”(您是否缺少 using 指令或程序集引用?) - CS0246 The type or namespace name 'ErrorViewModel' could not be found (are you missing a using directive or an assembly reference?) 错误 CS0246:找不到类型或命名空间名称“BannerPosition”是否缺少 using 指令或程序集引用? - error CS0246: The type or namespace name 'BannerPosition' could not be found are you missing a using directive or an assembly reference? 错误 CS0246 找不到类型或命名空间名称“CreateRandomAnswersForKey”(您是否缺少 using 指令或程序集引用?)? - Error CS0246 The type or namespace name 'CreateRandomAnswersForKey' could not be found (are you missing a using directive or an assembly reference?)? 错误 CS0246:找不到类型或命名空间名称“Npgsql”(您是否缺少 using 指令或程序集引用?) - error CS0246: The type or namespace name 'Npgsql' could not be found (are you missing a using directive or an assembly reference?) CS0246:找不到类型或命名空间名称'MySql'(您是否缺少using指令或程序集引用 - CS0246: The type or namespace name 'MySql' could not be found (are you missing a using directive or an assembly reference
 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM