У меня есть 3 таких класса, и я использовал код первого лица на .net
public class PersonModel
{
[Key]
public int PersonID { get; set; }
public string FullName { get ; set ; }
public string Phone { get ; set ; }
public string Adress { get; set ; }
public int NationalNumber { get ; set ; }
public List<SpecialtyToPersonModel> SpecialtyToPerson { get ; set ; }
}
public class SpecialtyModel
{
[Key]
public int SpecialtyID { get; set; }
public string SpecialtyName { get; set; }
public List<SpecialtyToPersonModel> SpecialtyToPerson { get; set; }
}
public class SpecialtyToPersonModel{
[Key]
public int SpecialtyToPersonID { get ; set ; }
public SpecialtyModel Specialty { get; set; }
public PersonModel Person { get;set; }
}
, когда мне нужно использовать specialityToPersonModel, например,
var db = new EntityContext();
var aaa = db.SpecialtyToPersons;
return aaa.ToList(); // so Simple !
или вот так:
var db = new EntityContext();
var aaa = db.SpecialtyToPersons
.Include(x=>x.Specialty)
.Include(x=>x.Person);
return aaa.ToList();
, выкидывает меня с этой ошибкой:
Ошибка Picture
An exception of type 'Npgsql.PostgresException' occurred in Microsoft.EntityFrameworkCore.dll but was not handled in user code: 'External component has thrown an exception.'