加入收藏 | 设为首页 | 会员中心 | 我要投稿 李大同 (https://www.lidatong.com.cn/)- 科技、建站、经验、云计算、5G、大数据,站长网!
当前位置: 首页 > 编程开发 > asp.Net > 正文

asp.net – 外键在VS2012 RC中未被识别

发布时间:2020-12-15 23:28:31 所属栏目:asp.Net 来源:网络整理
导读:在昨天帮助很大的帮助之后,我提出了一个已知错误的asp.net4 beta – 我升级到VS2012 RC Express(4.5),现在VS报告了我的模型中的两个错误,这是以前确定的: “无法找到类型或命名空间名称”ForeignKeyAttribute“(您是否缺少using指令或程序集引用?)” “无
在昨天帮助很大的帮助之后,我提出了一个已知错误的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已经在模式命名空间下移动.

希望这有助于别人,

谢谢,马克

(编辑:李大同)

【声明】本站内容均来自网络,其相关言论仅代表作者个人观点,不代表本站立场。若无意侵犯到您的权利,请及时与联系站长删除相关内容!

    推荐文章
      热点阅读