私はasp.net MVCが初めてです。データベース ビューからデータを取得し、それをモデルにマップしたいと考えています。モデル クラスには、ビューと同じプロパティ セットがあります。テーブルの代わりに db ビューからデータを取得する方法はありますか (コードが最初にあるため、テーブルは自動的に作成されます)。
私のモデルは次のようになります。
public class Product{
public long ID { get; set; }
[Display(Name = "Product Code")]
public int ProductCode { get; set; }
[Display(Name = "Product Title")]
public string ProductTitle { get; set; }
};
public class ProductDBContext : DbContext
{
public DbSet<Product> Products
{
get; set; }
}