I have the following:
class Employee {
[Key]
public int EmployeeID {get;set;}
public List<TimeSensitiveData> JobTitle {get;set;}
public List<TimeSensitiveData> Department {get;set;}
public List<TimeSensitiveData> OfficeLocation {get;set;}
}
abstract class TimeSensitiveData {
[Key]
public int TimeSensitiveDataID {get;set;}
public string Value1 {get;set;}
public DateTime Date {get;set;}
}
class JobTitle : TimeSensitiveData {}
class Department : TimeSensitiveData {}
class OfficeLocation : TimeSensitiveData {}
seed method looks something like this:
seed () {
List<TimeSeriesData> oflc = new List<TimeSeriesData>();
TimeSeriesData oflc2 = new OfficeLocation();
oflc2.Value1 = "New York";
oflc.Add(oflc2);
List<TimeSeriesData> dpt = new List<TimeSeriesData>();
TimeSeriesData dpt2 = new Department();
dpt2.Value1 = "New York";
dpt.Add(dpt2);
List<TimeSeriesData> jt = new List<TimeSeriesData>();
TimeSeriesData jt2 = new JobTitle();
jt2.Value1 = "New York";
jt.Add(jt2);
var Employees = new List<Employee> {
new Employee{JobTitle=jt,Department=dpt,OfficeLocation=oflc},
}
}
when I seed the database with employees it creates an employees table and a TimeSensitiveData table. In the TimeSensitiveData table there is a Discriminator column (which I know what it's doing) but there are also multiple Employee_EmployeeID columns. Actually, it seems like its creating one for every complex object that extends TimeSensitiveData.
so the TimeSensitiveData table looks kind of like this
TimeSensitiveDataID Value1 Date Discriminator Employee_EmployeeID Employee_EmployeeID1 Employee_EmployeeID2
1 xx date JobTitle NULL NULL(or value) NULL
2
etc..
etc..
I'm not sure why this is happening, any ideas?
should I make the Lists in the employee model not TimeSensitiveData type lists? should they be concrete class type lists?
[InverseProperty]部分修复了它
The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.