[英]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.