经过昨天的大量帮助,我在 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 引用是否已更改?
谢谢你的帮助,
标记