[英]Cannot create Controller with actions using Entity Framework
I've created a Model using Model first and Entity Data Model of Entity Framework. 我已经使用实体模型的第一个模型和实体数据模型创建了一个模型。 Well, when I want to create the controller (right click on controllers folder Add->controller->WebApi 2 Controller with actions using EF) then I become after defining the inputfields an error message: there was an error getting the type "WebApi.Models.QR_Name".
好吧,当我想创建控制器时(右键单击controllers文件夹Add-> controller-> WebApi 2 Controller,其中包含使用EF的操作),然后在定义输入字段后出现错误消息:获取类型为“ WebApi。 Models.QR_Name”。 Try rebuilding the project.
尝试重建项目。 The same error getting by the other Model class.
由其他Model类获得的相同错误。 How can I solve this??
我该如何解决?
EDIT: 编辑:
I have two classes: //Group 我有两个班://组
namespace WebApi.Models
{
public partial class QR_Group
{
public QR_Group()
{
this.QR_Name = new HashSet<QR_Name>();
}
public int Id { get; set; }
public string name { get; set; }
public string code { get; set; }
public virtual ICollection<QR_Name> QR_Name { get; set; }
}
}
//Name //名称
namespace WebApi.Models
{
public partial class QR_Name
{
public int Id { get; set; }
public string firstname { get; set; }
public double maxAge { get; set; }
public int QR_GroupId { get; set; }
public virtual QR_Group QR_Group { get; set; }
}
}
Additionally is here the Context class: 另外这里是Context类:
namespace WebApi.Models
{
public partial class WebApiContext : DbContext
{
public WebApiContext()
: base("name=WebApiContext")
{
}
protected override void OnModelCreating(DbModelBuilder modelBuilder)
{
throw new UnintentionalCodeFirstException();
}
public virtual DbSet<QR_Group> QR_Groups { get; set; }
public virtual DbSet<QR_Name> QR_Names { get; set; }
}
}
在创建控制器之前,请按Ctrl + Shift + B组合键来构建您的解决方案,或转到“构建->构建解决方案”,然后尝试创建控制器。
声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.