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
sangeetha k
NA
207
51.6k
Asp.net MVC: the underlying provider failed to open.
Dec 20 2017 1:40 AM
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.
Reply
Answers (
3
)
WebApi With Angularjs
commission rate display wrong when write commission textbox1