I have built a DAL dll using EF6, Devart dotConnect 9.1.131 .Net Framework 4.5.2 and am using it in a WPF application that's pretty simple. The DAL has four table in it: Employee, Department, PlantDtl, and TimeSubmitType... The WPF application main purpose is to add a new employee when hired... In the viewmodel's constructor, it reads a list of departments and displays them in a combobox(in the view...). The app has all the other pertinent details of the employee on it as well... At the bottom is a submit button. In it's command method I call one other method that tries to add the new employee to the dbcontext and save changes... I get an dbUpdateException when I do. I've used the dbmonitor app and it looks like the app is trying to insert back into the department table??? I didn't change anything there, so why is it trying to insert into THAT table??? Here's the code where I'm getting the error:
Code: Select all
private void AddEmployee()
{
using (var dc = new MTDAL.MTDALEntities())
{
dc.Employees.Add(NewEmployee);
try
{
_myMonitor.IsActive = true;
dc.SaveChanges();
}
catch(DbUpdateException ex)
{
throw;
}
}
}
Code: Select all
public MainViewModel()
{
_myMonitor = new OracleMonitor();
using (var dc = new MTDAL.MTDALEntities())
{
TimeSubmitTypes = new ObservableCollection<TimeSubmitType>(dc.TimeSubmitTypes);
DepartmentList = new ObservableCollection<Department>(dc.Departments.Ordered());
SupervisorList = new ObservableCollection<Employee>(dc.Employees.FindAllSupervisors());
NewEmployee = new Employee();
}
RoundingVisible = false;
SelectedVoucherIndex = -1;
SelectedDeptIndex = -1;
SelectedShiftIndex = -1;
SelectedTimeClockIndex = -1;
}
Thanks in advance,
Kevin Orcutt