TECHNOLOGIES
FORUMS
JOBS
BOOKS
EVENTS
INTERVIEWS
Live
MORE
LEARN
Training
CAREER
MEMBERS
VIDEOS
NEWS
BLOGS
Sign Up
Login
No unread comment.
View All Comments
No unread message.
View All Messages
No unread notification.
View All Notifications
Answers
Post
An Article
A Blog
A News
A Video
An EBook
An Interview Question
Ask Question
Forums
Monthly Leaders
Forum guidelines
mevada kamlesh
NA
66
29.2k
Asp.net MVC: the underlying provider failed to open. error
Mar 27 2018 5:43 AM
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.
Reply
Answers (
4
)
i find a error to restore backup file
how does session work in website if 100 user login in a time