EntityTypeBuilder does not contain a definition for ToTable in EF Core

前端 未结 12 1458
南笙
南笙 2021-02-06 20:22

I have this sample code:

using Microsoft.EntityFrameworkCore;
using Microsoft.EntityFrameworkCore.Metadata.Builders;
using Models;

namespace MySampleNamespace
{         


        
12条回答
  •  情深已故
    2021-02-06 20:57

    For me, my issue was that I trying to call ToView() incorrectly.

    I was doing:

     modelBuilder.Query(entity =>
            {
                entity.Property(v => v.VendorId).HasColumnName("VendorID");
                entity.Property(v => v.Name).HasColumnName("Vendor Name");                
            }).ToView("vwVendors");
    

    instead of:

    modelBuilder.Query(entity =>
            {
                entity.ToView("vwVendors");
                entity.Property(v => v.VendorId).HasColumnName("VendorID");
                entity.Property(v => v.Name).HasColumnName("Vendor Name");                
            });
    

提交回复
热议问题