Entity Framework mapping exclude database table columns

1.1k views Asked by At

I have a table in database named product and it has many columns:

  • Id
  • Name
  • Price
  • Size
  • Color
  • ....
  • ..

I want to create a class to represent this table only 3 columns. And I will map like this.

public class ProductConfiguration : EntityTypeConfiguration<Product>
{
    public ProductConfiguration()
    {
        ToTable("product");

        Property(p => p.ProductId).HasColumnName("id");
        Property(p => p.Name).HasColumnName("name");
        Property(p => p.Price).HasColumnName("price");
    }
}

How can I exclude database columns from mapping class?

0

There are 0 answers