0

이 오류가 발생합니다. 'modelBuilder'라는 이름이 현재 컨텍스트에 존재하지 않습니다.이 Entity Framework Core이고 Visual Studio 2017 및 Asp.Net Core를 사용하고 있습니다. 2.0'modelBuilder'이름이 현재 컨텍스트에 없습니다.

Entity Framework 6에서는 다음 코드를 사용하여 엔터티를 분할합니다. 이제 Visual Studio 2017 및 Entity Framework Core 2.0을 사용하고 있는데 modelBuilder.Entity를 사용할 때 "modelBuilder '라는 이름이 현재 컨텍스트에 존재하지 않습니다"라는 메시지가 표시됩니다. <>()

나는 그것이 더 분명하다고 생각합니다. 지금.

public partial class Model : DbContext 
{ 
    public Model() : base("name=EntityModel") 
    { 
     Database.Log = Console.WriteLine; 
} 
public virtual DbSet<Employee> Employees { get; set; } 

protected override void OnModelCreating(DbModelBuilder modelBuilder) 
{ 
    modelBuilder.Entity<Employee>() 
    .Map(map => 
    { 
    map.Properties(p => new 
    { 
    p.EmployeeId, 
    p.Name, 
    p.Code 
    }); 
    map.ToTable("Employee"); 
    }) 
    // Map to the Users table 
    .Map(map => 
    { 
    map.Properties(p => new 
    { 
    p.PhoneNumber, 
    p.EmailAddress 
    }); 
    map.ToTable("EmployeeDetails"); 
    }); 
} 
} 
+0

당신이 당신의 코드를 보여줄 수>

protected override void OnModelCreating(ModelBuilder modelBuilder) 

모델 빌더 대신 DbModelBuilder
ModelBuilder.Entity <의? –

답변