I've just started to learn ASP.Net MVC and Entity Framework using some tutorial and I have a problem.
I created class for Database Connection OdeToFoodDb.cs
using System;
using System.Collections.Generic;
using System.Data.Entity;
using System.Linq;
using System.Web;
namespace OdeToFood.Models
{
public class OdeToFoodDb : DbContext
{
public DbSet<Restaurant> Restaurants { get; set; }
public DbSet<RestaurantReview> Reviews { get; set; }
}
}
and two classes Restaurant.cs
using System;
using System.Collections.Generic;
using System.Linq;
using System.Web;
namespace OdeToFood.Models
{
public class Restaurant
{
public int Id { get; set; }
public string Name { get; set; }
public string City { get; set; }
public string Country { get; set; }
public ICollection<RestaurantReview> Review { get; set; }
}
}
and RestaurantReview.cs
using System;
using System.Collections.Generic;
using System.Linq;
using System.Web;
namespace OdeToFood.Models
{
public class RestaurantReview
{
public int Id { get; set; }
public int Rating { get; set; }
public string Body { get; set; }
public int RestaurantId { get; set; }
}
}
And I've got database but it doesn't contain tables RestaurantReviews or Restaurants
but my tutorial says that I get these tables automatically. What I did wrong? How to make it create tables I need?