Warning: file_get_contents(/data/phpspider/zhask/data//catemap/6/entity-framework/4.json): failed to open stream: No such file or directory in /data/phpspider/zhask/libs/function.php on line 167

Warning: Invalid argument supplied for foreach() in /data/phpspider/zhask/libs/tag.function.php on line 1116

Notice: Undefined index: in /data/phpspider/zhask/libs/function.php on line 180

Warning: array_chunk() expects parameter 1 to be array, null given in /data/phpspider/zhask/libs/function.php on line 181

Warning: file_get_contents(/data/phpspider/zhask/data//catemap/9/csharp-4.0/2.json): failed to open stream: No such file or directory in /data/phpspider/zhask/libs/function.php on line 167

Warning: Invalid argument supplied for foreach() in /data/phpspider/zhask/libs/tag.function.php on line 1116

Notice: Undefined index: in /data/phpspider/zhask/libs/function.php on line 180

Warning: array_chunk() expects parameter 1 to be array, null given in /data/phpspider/zhask/libs/function.php on line 181
Entity framework 实体框架5代码首先不映射模型_Entity Framework_C# 4.0_Ef Code First - Fatal编程技术网

Entity framework 实体框架5代码首先不映射模型

Entity framework 实体框架5代码首先不映射模型,entity-framework,c#-4.0,ef-code-first,Entity Framework,C# 4.0,Ef Code First,我一直在与EF5合作,试图构建一个应用程序,但遇到了一个小问题 我创建了一个模型,如 public class TargetBusinessModel { public int Id { get; set; } public Guid BusinessId {get; set; } public Business Business { get; set; } public string ContactName { get; set; } public s

我一直在与EF5合作,试图构建一个应用程序,但遇到了一个小问题

我创建了一个模型,如

 public class TargetBusinessModel
{
    public int Id { get; set; }
    public Guid BusinessId {get; set; }
    public Business Business { get; set; }
    public string ContactName { get; set; }
    public string ContactTitle { get; set; }
    public string ContactPhone { get; set; }
}
更新了上下文文件

  public DbSet<TargetBusinessModel> TargetBusinessModels { get; set; }
public DbSet TargetBusinessModels{get;set;}
我的问题是,业务中的所有属性都没有映射到数据库中

我试图添加的商业模式来自另一个项目,我不确定这是否是原因

我不介意代码首先为我的业务模型创建一个单独的表,还是将它们组合在一起


有人能帮忙吗?

尝试将
业务
实体的
DbSet
添加到您的
DbContext
实现中:

public DbSet<Business> Businesses { get; set; }
公共数据库集业务{get;set;}

谢谢,答案是:)