在昨天帮助很大的帮助之后,我提出了一个已知错误的asp.net4 beta – 我升级到VS2012 RC Express(4.5),现在VS报告了我的模型中的两个错误,这是以前确定的:
“无法找到类型或命名空间名称”ForeignKeyAttribute“(您是否缺少using指令或程序集引用?)”
“无法找到类型或命名空间名称”ForeignKey“(您是否缺少using指令或程序集引用?)”
- 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引用是否已更改?
感谢任何帮助,
解决方法
我只是想出了我需要补充:
- using System.ComponentModel.DataAnnotations.Schema;
我以前不需要移动它,所以我假定ForeignKey已经在模式命名空间下移动.
希望这有助于别人,
谢谢,马克