I have a simple class called Applicant. I'm trying to add a template controller using the Entity Framework with Applicant as my model class, and a new data context.
Every time I try to create the controller, I get an error dialog that says "Unable to retrieve metadata for 'MyNameSpace.Models.Applicant'. There was an error generating 'ScaffoldingConnectionFactory'. Try rebuilding your project."
Rebuilding does nothing.
Here is my model class:
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; }
}
}
I feel like I've missed a step but I can't put my finger on it.