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
yash patel
1.5k
283
21k
Here i am getting an exception
Sep 26 2020 5:20 AM
The 1st table i.e. user table the data is saving but in the second table user i.e. user address it is not the following exception is coming
can anyone tell how to overcome this exception
Exception thrown: 'System.Data.Entity.Infrastructure.DbUpdateException' in EntityFramework.dll
Additional information: An error occurred while updating the entries. See the inner exception for details.
In addition to this i have 2 tables user and user address
USER = user id(primary key)
name
email
password
ADDRESS=addressid (primary key)
address
city
state
user id (foreign key from user table with primary key user id)
identity specification for both the primary keys is on.
public
CustomBO AddUser( UserBO objUserBO )
{
CustomBO objCustomBO =
new
CustomBO();
User objUser =
new
User();
{
objUser.UserEmail = objUserBO.UserEmail;
objUser.FullName = objUserBO.FullName;
objUser.Password = objUserBO.Password;
};
objnsrouteEntities.Users.Add(objUser);
objnsrouteEntities.SaveChanges();
return
objCustomBO;
}
public
CustomBO AddUserAddress( UserBO objUserBO )
{
CustomBO objCustomBO =
new
CustomBO();
UserAddress objUserAddress =
new
UserAddress();
{
objUserAddress.CompleteAddress = objUserBO.CompleteAddress;
objUserAddress.City = objUserBO.City;
objUserAddress.State = objUserBO.State;
}
//objUserAddress.UserId = objUserBO.UserId;
objnsrouteEntities.UserAddresses.Add(objUserAddress);
objnsrouteEntities.SaveChanges();
return
objCustomBO;
}
Reply
Answers (
1
)
Display script as text
Console App Question