无法检索abc.models.abcviewmodel的元数据

时间:2014-04-02 11:19:21

标签: asp.net-mvc razor

我有一个ViewModel

    public class abcViewModel
     {
        public List<tblUserTeam> UserTeam { get; set; }
     }

    public partial class tblUserTeam
    {
       public int UserId { get; set; }
       public int MatchId { get; set; }
       public int PlayerId { get; set; }
       [Display(Name = "Caption")]
       public Nullable<bool> IsCaption { get; set; }

       public virtual tblMatch tblMatch { get; set; }
       public virtual tblPlayer tblPlayer { get; set; }
       public virtual tblUser tblUser { get; set; }
    }

  public partial class tblMatch
    {
        public tblMatch()
        {
            this.tblScores = new HashSet<tblScore>();
            this.tblUserTeams = new HashSet<tblUserTeam>();
        }

        public int MatchId { get; set; }
        public Nullable<System.DateTime> MatchDateTime { get; set; }
        public Nullable<int> Team1 { get; set; }
        public Nullable<int> Team2 { get; set; }
        public string Location { get; set; }

        public virtual tblTeam tblTeam { get; set; }
        public virtual tblTeam tblTeam1 { get; set; }
        public virtual ICollection<tblScore> tblScores { get; set; }
        public virtual ICollection<tblUserTeam> tblUserTeams { get; set; }
    }
public partial class tblPlayer
    {
        public tblPlayer()
        {
            this.tblScores = new HashSet<tblScore>();
            this.tblUserTeams = new HashSet<tblUserTeam>();
        }

        public int playerId { get; set; }
        [Display(Name = "Player")]
        public string PlayerName { get; set; }
        public Nullable<int> TeamId { get; set; }
        public Nullable<int> CountryId { get; set; }
        public string StatisticsWebsite { get; set; }
        public System.DateTime dtCreated { get; set; }
        public Nullable<int> Price { get; set; }
        public Nullable<int> Speciality { get; set; }

        public virtual tblCountry tblCountry { get; set; }
        public virtual tblPlayerSpeciality tblPlayerSpeciality { get; set; }
        public virtual tblTeam tblTeam { get; set; }
        public virtual ICollection<tblScore> tblScores { get; set; }
        public virtual ICollection<tblUserTeam> tblUserTeams { get; set; }
    }
public partial class tblUser
    {
        public tblUser()
        {
            this.tblUserTeams = new HashSet<tblUserTeam>();
        }

        public int UserId { get; set; }
        public string Username { get; set; }
        public string Password { get; set; }
        public string Email { get; set; }
        public Nullable<System.DateTime> dtCreated { get; set; }
        public string TeamName { get; set; }

        public virtual ICollection<tblUserTeam> tblUserTeams { get; set; }
    }

当我尝试使用脚手架创建控制器和上面的viewmodel视图时,我收到此错误&#34;无法检索abc.models.abcviewmodel&#34;

的元数据

请指导我这是错误的。

2 个答案:

答案 0 :(得分:2)

如果您是从poco生成的,请确保在“添加控制器”或“添加视图”对话框中没有设置数据上下文类。

答案 1 :(得分:0)

只需编译并构建一次代码,然后再试一次,因为它使用反射来识别模型。