I have this sample code:
using Microsoft.EntityFrameworkCore;
using Microsoft.EntityFrameworkCore.Metadata.Builders;
using Models;
namespace MySampleNamespace
{
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");
});