本文介绍了错误发生ScaffoldingConnectionFactory的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

限时删除!!

我有一个名为申请人简单的类。我尝试添加使用Entity Framework和申请人作为我的模型类的模板控制器,以及一个新的数据环境。

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.

每次我试图创建控制器,我得到一个错误对话框,显示无法检索元数据MyNameSpace.Models.Applicant'。有一个错误发生ScaffoldingConnectionFactory。尝试重建项目。

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."

重建什么都不做。

下面是我的模型类:

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.

推荐答案

我有同样的问题,不得不同样修复它。

I had the same problem and had to fix it similarly.

我的EF的版本是与新的MVC工具不兼容。从更新的NuGet的EntityFramework,并作出一些更新过时的code之后,一切工作正常。

My version of EF was incompatible with the new MVC tooling. After updating EntityFramework from NuGet, and making a few updates to outdated code, everything is working fine.

这篇关于错误发生ScaffoldingConnectionFactory的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持!

1403页,肝出来的..

09-06 12:42