经过昨天的大量帮助,我在 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参考是否已更改?
谢谢你的帮助,
Mark
我刚刚发现我需要添加:
using System.ComponentModel.DataAnnotations.Schema;
我之前不需要移动它,所以我假设foreignkey已被移动到模式命名空间下。
希望这对其他人有帮助,
谢谢,马克
本文内容由网友自发贡献,版权归原作者所有,本站不承担相应法律责任。如您发现有涉嫌抄袭侵权的内容,请联系:hwhale#tublm.com(使用前将#替换为@)