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;
- }
-
- objnsrouteEntities.UserAddresses.Add(objUserAddress);
- objnsrouteEntities.SaveChanges();
- return objCustomBO;
- }