Before you say that this is an answered question, I checked everything I found on this subject and nothing works for me.
I am watching a tutorial about entity framework and doing a project in .net MVC. I have created the following class:
namespace ShowReel.Models
{
public class ShowReelDB : DbContext
{
public DbSet<Tvshow> Tvshows { get; set; }
public DbSet<EpisodeGuide> Episode { get; set; }
}
}
I am supposed to open a connection to a local database, and on the tutorial as an option to a database, it gives this DBContext class.
I get only this:
If I enter it manually, then it creates a new empty database, but it is supposed to create a database that has the tables Tvshows and Episode.
Can anyone tell me what's the problem? Do I need to install anything else to the Visual Studio?
I apologize if this is a stupid question but I am fairly new to .net mvc, and I am trying to learn it right now.
Here is the connectionstring:
<connectionStrings>
<add name="DefaultConnection" connectionString="Data Source=(LocalDb)\MSSQLLocalDB;AttachDbFilename=|DataDirectory|\aspnet-ShowReel-20170214120508.mdf;Initial Catalog=aspnet-ShowReel-20170214120508;Integrated Security=True" providerName="System.Data.SqlClient" />
And here is what I have for the entity framework in the web.config file:
<entityFramework>
<defaultConnectionFactory type="System.Data.Entity.Infrastructure.LocalDbConnectionFactory, EntityFramework">
<parameters>
<parameter value="mssqllocaldb" />
</parameters>
</defaultConnectionFactory>
<providers>
<provider invariantName="System.Data.SqlClient" type="System.Data.Entity.SqlServer.SqlProviderServices, EntityFramework.SqlServer" />
</providers>
EDIT:
When running the app, I get the following error:

The model from where I call the database is this one:
// GET: TVShows
ShowReelDB _db = new ShowReelDB();
public ActionResult TVshow()
{
var model = _db.Tvshows.ToList();
return View(model);
}
And here are the elements of the Tvshow and Episode table:
public class EpisodeGuide
{
public int Id { get; set; }
public string Name { get; set; }
public int Seasons { get; set; }
public Array EpisodesPerSeason { get; set; }
public DateTime Date { get; set; }
}
public class Tvshow
{
public int Id { get; set; }
public string Type { get; set; }
public string Name { get; set; }
public string Description { get; set; }
public double Rating { get; set; }
public string Image { get; set; }
public int Year { get; set; }
public int EpisodeGuideID { get; set; }
}
The view is the following:
@foreach (var item in Model)
{
<div class="row">
<div class="col-md-4">
<img src="../Content/Images/@item.Image" style="height:200px; width:300px;" />
</div>
<div class="col-md-8">
<h2> @Html.DisplayFor(modelItem => item.Name)</h2>
<p> @Html.DisplayFor(modelItem => item.Description)</p>
<button class="btn btn-danger btn-lg news" id="@Html.DisplayFor(modalItem => item.Id)">Track</button>
</div>
</div>
<hr />
}
