I'm using Entity Framework with MVC4. I'm not sure how to add my ViewModel to my dbcontext. Is it as simple as declaring it in my DbContext? Basically I wish to use my view model in my controller and pass it to my view. I've run into many many problems trying to accomplish this.
namespace BagInventory.Models
{
using System;
using System.Data.Entity;
using System.Data.Entity.Infrastructure;
public partial class FreshouseSalesEntities : DbContext
{
public FreshouseSalesEntities()
: base("name=FreshouseSalesEntities")
{
}
protected override void OnModelCreating(DbModelBuilder modelBuilder)
{
throw new UnintentionalCodeFirstException();
}
public DbSet<Materials_Packer> Materials_Packer { get; set; }
public DbSet<Materials_Product> Materials_Product { get; set; }
public DbSet<Materials_PackerProduct> Materials_PackerProduct { get; set; }
public DbSet<Materials_Vendor> Materials_Vendor { get; set; }
public DbSet<Materials_Log> Materials_Log { get; set; }
//Below is my view model I wish to add to dbcontext
public DbSet<BigViewModel> BigViewModel{get;set;}
}
}
is this the correct way of doing this?