我有一个简单的类叫做申请人。我试图添加一个模板控制器,使用Entity Framework作为我的模型类和一个新的数据上下文。生成脚手架连接工厂时出错
每次尝试创建控制器时,都会出现一个错误对话框,提示“无法检索'MyNameSpace.Models.Applicant'的元数据,产生'ScaffoldingConnectionFactory'错误,尝试重建项目。
重建不做任何事情。
这里是我的模型类:
using System;
using System.Collections.Generic;
using System.Linq;
using System.Web;
using System.ComponentModel.DataAnnotations;
namespace MyNameSpace.Models
{
public class Applicant
{
public int ApplicantId { get; set; }
[Required]
public string FirstName { get; set; }
[Required]
public string LastName { get; set; }
public string MiddleInitial { get; set; }
[Required]
public string Phone { get; set; }
[Required]
public string EmailAddress { get; set; }
[Required]
[DataType(DataType.Date)]
public string DateOfBirth { get; set; }
public virtual Ethnicity Ethnicity { get; set; }
public virtual Race Race { get; set; }
}
public class Ethnicity
{
public int EthnicityId { get; set; }
public string Type { get; set; }
}
public class Race
{
public int RaceId { get; set; }
public string Type { get; set; }
}
}
我觉得我已经错过了一步,但我不能把我的手指上。
为了完成这项工作,做了哪些更新和更改?你能否详细说明这个答案实际上有用? – renegadeMind 2012-05-11 17:37:42