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
Abdulmajeed Alshari
NA
266
61.3k
solve db.SaveChanges() exception MVC5
Jan 15 2018 3:33 PM
I am using
code first approach
when call SaveChanges function appears Exception message ,my Code is :
public
ActionResult Create(JobSeekerMore AllJobSeekerInfos, HttpPostedFileBase[] acadimicCertificate)
{
HttpPostedFileBase img;
JobSeekerInfo jobSeekerInfo =
new
JobSeekerInfo();
var userID = User.Identity.GetUserId();
string
path;
string
fileName;
int
i = 0;
AcadimicDetail acadimi;
if
(ModelState.IsValid)
{
i = 0;
foreach
(AcadimicDetail item
in
AllJobSeekerInfos.MoreAcadimicDetials)
{
acadimi =
new
AcadimicDetail();
acadimi = item;
fileName = userID +
"acadimicCertificate"
;
acadimi.acadimicCertificate = fileName;
img = acadimicCertificate[i];
path = Path.Combine(Server.MapPath(
"~/Uploads/"
), fileName);
img.SaveAs(path);
++i;
acadimi.JobSeekerId = userID;
db.AcadimicDetails.Add(acadimi);
try
{
db.SaveChanges();
}
catch
(Exception ee)
{
string
mes = ee.InnerException.Message;
Exception d=
new
Exception();
object
f = ee.InnerException.Data;
f = ee.InnerException.HelpLink;
f = ee.InnerException.HResult;
f = ee.InnerException.Source;
f = ee.HelpLink;
f = ee.HResult;
f = ee.Source;
f = ee.Data;
string
tem = ee.StackTrace;
}
}
}
and
The Model of Table
is as :
public
class
AcadimicDetail
{
public
int
Id {
get
;
set
; }
public
string
acadimicName {
get
;
set
; }
public
string
acadimicType {
get
;
set
; }
public
string
acadimicTitle {
get
;
set
; }
public
DateTime acadimicEndDate {
get
;
set
; }
public
string
acadimicCountry {
get
;
set
; }
public
string
acadimicCity {
get
;
set
; }
public
string
acadimicCertificate {
get
;
set
; }
public
string
JobSeekerId {
get
;
set
; }
}
and the
JobSeekerMore ViewModel
is as :
public
class
JobSeekerMore
{
public
List MoreAcadimicDetials {
get
{
return
_MoreAcadimicDetials; } }
private
List _MoreAcadimicDetials =
new
List();
}
Now when Enter the below values into AcadimicDetail table
are as :
Id=0 JobSeekerId="66a41cbf-0545-4a31-bc95-634af3a6b16b"
acadimicCertificate = "66a41cbf-0545-4a31-bc95-634af3a6b16bacadimicCertificate"
acadimicCity = "New Yourk"
acadimicCountry="USA"
acadimicEndDate = {1/1/0001 12:00:00 AM}
acadimicName="Teacher"
acadimicTitle="English"
acadimicType = "female"
the Exception Details are as :
InnerException Message "An error occurred while updating the entries. See the inner exception for details."
HResult = -2146233087
InnerException.Source = "EntityFramework"
StackTrace
at System.Data.Entity.Internal.InternalContext.SaveChanges()
at System.Data.Entity.Internal.LazyInternalContext.SaveChanges()
at System.Data.Entity.DbContext.SaveChanges()
at jobPortal.Controllers.JobSeekerInfoesController.Create(JobSeekerMore AllJobSeekerInfos, HttpPostedFileBase[] acadimicCertificate)
Reply
Answers (
3
)
The request was aborted: Could not create SSL/TLS secure cha
Not able to call controller method