I have created asp.Net MVC application (code first approach). If I run Index.cshtml file, then it arises following error message in the browser.
"The system cannot find the file specified"
Error Shows in this line
Line 26: db.Standards.Add(standard1);
If it runs successfully, then it must create Database in App_Data folder. But this Index.cshtml is not running successfully. Please guide that how to resolve this problem.
In Visual Stusdio 2015->File->New->Project->Asp.Net Web Application, Name of Project:Note7Page55->Seelect MVC option->ok.
Model Folder->Student.cs
- namespace Note7Page55.Models
- {
- public class Student
- {
- public int StudentId { get; set; }
- public string StudentName { get; set; }
- public string Address { get; set; }
- public string City { get; set; }
- public Standard Standard { get; set; }
- }
- }
Model Folder->Standard.cs
- using System.Collections.Generic;
- namespace Note7Page55.Models
- {
- public class Standard
- {
- public int StandardId { get; set; }
- public string StandardName { get; set; }
- public ICollection
Students { get; set; } - }
- }
Model Folder->SchoolContext.cs
- using System.Data.Entity;
- namespace Note7Page55.Models
- {
- public class SchoolContext : DbContext
- {
- public SchoolContext() : base(){}
- public DbSet
Standards { get; set; } - public DbSet
Students { get; set; } - }
- }
Controller Folder-> SchoolController.cs
- using System.Web.Mvc;
- using Note7Page55.Models;
- namespace Note7Page55.Controllers
- {
- public class SchoolController : Controller
- {
- SchoolContext db = new SchoolContext();
- // GET: School
- public ActionResult Index()
- {
- Standard standard1 = new Standard()
- {
- StandardName = "Std. 5th"
- };
- Student student1 = new Student()
- {
- StudentName = "Dinesh Kudale",
- Address = "Gar Fata",
- City = "Patas"
- };
- db.Standards.Add(standard1);
- db.Students.Add(student1);
- db.SaveChanges();
- return View();
- }
- }
- }
- @model Note7Page55.Models.Student
- @{
- ViewBag.Title = "Index";
- }
Index
"The system cannot find the file specified"
Please guide that how to resolve this problem.

Dinesh KudalePosted Jul 7, 2018, 4:38 AM
Manav PandyaPosted Jul 6, 2018, 5:11 AM
Dinesh KudalePosted Jul 6, 2018, 5:01 AM
Manav PandyaPosted Jul 6, 2018, 4:40 AM