I use sql management studio 2016
Here is the screen:
Code in View (Index.cshtml):
@model IEnumerable<WebApplication1.Models.Book> @{ Layout = "~/Views/Shared/_Layout.cshtml"; } <div> <h3>Π Π°ΡΠΏΡΠΎΠ΄Π°ΠΆΠ° ΠΊΠ½ΠΈΠ³</h3> <table> <tr class="header"> <td><p>ΠΠ°Π·Π²Π°Π½ΠΈΠ΅ ΠΊΠ½ΠΈΠ³ΠΈ</p></td> <td><p>ΠΠ²ΡΠΎΡ</p></td> <td><p>Π¦Π΅Π½Π°</p></td> <td></td> </tr> @foreach (WebApplication1.Models.Book b in Model) { <tr> <td><p>@b.Name</p></td> <td><p>@b.Author</p></td> <td><p>@b.Price</p></td> <td><p><a href="/Home/Buy/@b.Id">ΠΡΠΏΠΈΡΡ</a></p></td> </tr> } </table> </div> WebConfig:
<connectionStrings> <add name="BookContext" connectionString="Data Source=(LocalDB)\MSSQLLocalDB;AttachDbFilename='|DataDirectory|\Bookstore.mdf';Integrated Security=True" providerName="System.Data.SqlClient"/> </connectionStrings> HomeController:
BookContext db = new BookContext(); public ActionResult Index() { return View(db.Books); } protected override void Dispose(bool disposing) { db.Dispose(); base.Dispose(disposing); } BookContext:
public class BookContext : DbContext { public BookContext() : base("DefaultConnection") { } public DbSet<Book> Books { get; set; } public DbSet<Purchase> Purchases { get; set; } } In Bd there is data:
Perhaps the fact is that after starting the database is turned off? : 


public BookContext() : base("DefaultConnection")topublic BookContext() : base("name=BookContext") { }- Vadim Prokopchuk