Help me where I am wrong
Here with I attach my mvc code.
#view
- @model Mvcpractice1.Models.Employee
- @{
- ViewBag.Title = "Employee Details";
- }
- <h2>Employee Details</h2>
- <table>
- <tr>
- <td>
- <b>Employee Id:</b>
- </td>
- <td>
- @Model.EmployeeId
- </td>
- </tr>
- <tr>
- <td><b>Employee Phoneno:</b></td>
- <td>@Model.Phoneno</td>
- </tr>
- <tr>
- <td><b>Employee Name:</b></td>
- <td>@Model.Name</td>
- </tr>
- </table>
#controller
- using System;
- using System.Collections.Generic;
- using System.Linq;
- using System.Web;
- using System.Web.Mvc;
- using Mvcpractice1.Models;
- namespace Mvcpractice1.Controllers
- {
- public class EmployeeController : Controller
- {
-
-
- public ActionResult Index( int id)
- {
- EmployeeContext emp=new EmployeeContext();
- Employee emp1= emp.Employees.Single(x=>x.EmployeeId == id);
- return View(emp1);
- }
- }
- }
#DbContetxt
- namespace Mvcpractice1.Models
- {
- public class EmployeeContext:DbContext
- {
- public DbSet<Employee> Employees { get; set; }
- }
- }
#webConfig
- <connectionStrings>
- <add name="EmployeeContext" connectionString="Data Source=CHV8LTDBNC01\LENTRACSDB2008;Integrated Security=True ;Database=AdventureWorks2008" providerName="System.Data.SqlClient" />
- </connectionStrings>
But this is yeilding
An exception of type 'System.Data.Entity.Core.EntityException' occurred in EntityFramework.SqlServer.dll but was not handled in user code
Additional information: The underlying provider failed on Open.