Mar*_*ark 13 asp.net asp.net-mvc asp.net-web-api visual-studio-2012
经过昨天的大量帮助后,我遇到了asp.net4测试版中的一个已知错误 - 我升级到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; }
}
Run Code Online (Sandbox Code Playgroud)
有谁知道ForeignKey引用是否已被更改?
谢谢你的帮助,
标记
Mar*_*ark 23
我刚想通了我需要添加:
using System.ComponentModel.DataAnnotations.Schema;
Run Code Online (Sandbox Code Playgroud)
我以前不需要移动它,所以我假设ForeignKey已经移动到架构命名空间下.
希望这有助于其他人,
谢谢,马克
| 归档时间: |
|
| 查看次数: |
7119 次 |
| 最近记录: |