I would like to ask about this problem please. this my code>
context :
public class ArchifeContext: DbContext
{
public DbSet<Department> Departments { get; set; }
public DbSet<Employee> Employees { get; set; }
public DbSet<Book> Books { get; set; }
}
Controller :
public ArchifeContext db = new ArchifeContext();
public ActionResult Index()
{
return View(db.Books.ToList());
}
This might be occurring because your database doesn't match your context, try to backup and delete old database and try again. If you don't wana do this then try to migrate changes to your database by using Enable-Migrations
and Update-Database
Try this.It worked for me
The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.