Help me where I am wrong
Here with I attach my mvc code.
#view
- @model MVCDemo2.Models.Employee
- @{
- ViewBag.Title = "Employee Details";
- }
- <h2>Employee Details</h2>
- <table style="font-family:Arial">
- <tr>
- <td>
- <b>Employee Id:</b>
- </td>
- <td>
- @Model.EmployeeId
- </td>
- </tr>
- <tr>
- <td>
- <b>Name:</b>
- </td>
- <td>
- @Model.Name
- </td>
- </tr>
- <tr>
- <td>
- <b>Gender:</b>
- </td>
- <td>
- @Model.Gender
- </td>
- </tr>
- <tr>
- <td>
- <b>City:</b>
- </td>
- <td>
- @Model.City
- </td>
- </tr>
- </table>
#controller
- using System;
- using System.Collections.Generic;
- using System.Linq;
- using System.Web;
- using System.Web.Mvc;
- using MVCDemo2.Models;
- namespace MVCDemo2.Controllers
- {
- public class EmployeeController : Controller
- {
- public ActionResult Details(int id)
- {
- EmployeeContext employeeContext = new EmployeeContext();
- Employee employee = employeeContext.Employees.Single(emp => emp.EmployeeId == id);
- return View(employee);
- }
- }
- }
#EmployeeContext
- using System;
- using System.Collections.Generic;
- using System.Linq;
- using System.Web;
- using System.Data.Entity;
-
- namespace MVCDemo2.Models
- {
- public class EmployeeContext : DbContext
- {
- public DbSet<Employee> Employees { get; set; }
- }
- }
#webConfig
- <connectionStrings>
- <add name="EmployeeContext" connectionString="Data Source=ADMIN-PC3\SQLEXPRESS;Initial Catalog=employee;Integrated Security=true"
- providerName="System.Data.SqlClient"/>
- </connectionStrings>
but Run time Error "EntityException was unhandled by user code" The Underlying provider failed on on Open.