FOREIGNKEY不是在VS2012 RC被认可 [英] ForeignKey not being recognised in VS2012 RC
问题描述
很多的帮助后,昨天,我想出了反对ASP.NET4测试已知的错误 - 我升级到VS2012 RC防爆preSS(4.5),现在是VS报告在我的模型,这是两个错误OK previously:
after a lot of help yesterday, I came up against a known error in asp.net4 beta - I upgraded to VS2012 RC Express (4.5), and now VS is reporting two errors in my model, which were ok previously:
的类型或命名空间名称ForeignKeyAttribute'找不到(是否缺少using指令或程序集引用?)
"The type or namespace name 'ForeignKeyAttribute' could not be found (are you missing a using directive or an assembly reference?)"
的类型或命名空间名称ForeignKey的'找不到(是否缺少using指令或程序集引用?)
"The type or namespace name 'ForeignKey' could not be found (are you missing a using directive or an assembly reference?)"
using System;
using System.Collections.Generic;
using System.Linq;
using System.Web;
using System.ComponentModel.DataAnnotations;
using System.Data.Entity.ModelConfiguration.Conventions;
using System.Data.Entity;
namespace MvcApplication6.Models
{
public class tblRental
{
[Key()]
public int rental_id { get; set; }
public int room_id { get; set; }
public DateTime check_in { get; set; }
public DateTime check_out { get; set; }
public decimal room_cost { get; set; }
public long customer_ref { get; set; }
[ForeignKey("customer_ref")]
public virtual tblCustomerBooking Customer { get; set; }
}
public class tblCustomerBooking
{
[Key()]
public long customer_id { get; set; }
public string customer_name { get; set; }
public string customer_email { get; set; }
public virtual ICollection<tblRental> Rentals { get; set; }
}
有谁知道,如果ForeignKey的参考已经被改变?
Does anyone know if the ForeignKey reference has been changed?
感谢您的帮助,
标记
推荐答案
我只是想通了,我需要添加:
I just figured out I needed to add:
using System.ComponentModel.DataAnnotations.Schema;
我并不需要移动之前,所以我想ForeignKey的已架构命名空间下移动。
I didn't need to move it before, so I assume ForeignKey has been moved under the schema namespace.
希望这有助于其他人,
谢谢,马克
这篇关于FOREIGNKEY不是在VS2012 RC被认可的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!