Tech
Forums
Jobs
Books
Events
Interviews
Live
More
Learn
Training
Career
Members
Videos
News
Blogs
Login
Sign Up
Ask Question
3
Reply
Asp.net MVC: the underlying provider failed to open.
sangeetha k
Dec 20 2017 1:40 AM
151
Reply
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
{
//
// GET: /Employee/
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.
Upload Source Code
Select only zip and rar file.
Post
Reset
Cancel
Answers (
3
)
Next Recommended Forum
System runtime interopservices comexception in VB windowsapp
commission rate display wrong when write commission textbox1