I'm trying to make a web application MVC4 in c#.
I'm using the same DB than the DB created initially for users (anuthentication) (more easy to deal in connexionstrings).
So I made 3 models and the models were find in DB. Now I added another entity as a model, but the model is'nt create in the mdf file.
How Can I create it from code or rebuild the DB, or...
For the moment, all works fine except with the controllers that are dealing of my latest entity (named "ItemsToBuy") because it doens't exist in DB indeed
Thanks to help me!
EDIT : CODE
namespace MvcShop.Models
{
public class ItemsToBuy
{
public int ItemsToBuyId {get; set;}
public Item Item { get; set; }
public int NumberItems { get; set; }
public string AddedBy { get; set; }
public DateTime AddedDate { get; set; }
public int ItemId { get; set; }
}
}
And the method that make the exception :
var itemstobuys = db.ItemsToBuy.Include(i => i.Item);
return View(itemstobuy.ToList());
With that Exception (InnerException) :
{"Invalid object name 'dbo.ItemsToBuys'."}

And the DBCOntext class :
namespace MvcShop.Models
{
public class ShopEntities : DbContext
{
public DbSet<Item> Item { get; set; }
public DbSet<ItemShop> ItemShop { get; set; }
public DbSet<ItemsToBuy> ItemsToBuy { get; set; }
public DbSet<Shop> Shop { get; set; }
}
}
and in global.asax as required :
public class MvcApplication : System.Web.HttpApplication
{
protected void Application_Start()
{
AreaRegistration.RegisterAllAreas();
WebApiConfig.Register(GlobalConfiguration.Configuration);
FilterConfig.RegisterGlobalFilters(GlobalFilters.Filters);
RouteConfig.RegisterRoutes(RouteTable.Routes);
BundleConfig.RegisterBundles(BundleTable.Bundles);
AuthConfig.RegisterAuth();
Database.SetInitializer<ShopEntities>(null);
}
}