0
votes

I'm making a Windows Service using Code First From Database, but my code is throwing the following exception. Where can I change Foreign Key configuration of this class, because it looks like that the columns are cross-referenced, the column usu_grpcom must refer codagp and usu_codemp must refer codemp.

e013agp_usu_titefol_Source_e013agp_usu_titefol_Target: : The types of all properties in the Dependent Role of a referential constraint must be the same as the corresponding property types in the Principal Role. The type of property 'usu_grpcom' on entity 'usu_titefol' does not match the type of property 'codemp' on entity 'e013agp' in the referential constraint 'e013agp_usu_titefol'.

e013agp_usu_titefol_Source_e013agp_usu_titefol_Target: : The types of all properties in the Dependent Role of a referential constraint must be the same as the corresponding property types in the Principal Role. The type of property 'usu_codemp' on entity 'usu_titefol' does not match the type of property 'codagp' on entity 'e013agp' in the referential constraint 'e013agp_usu_titefol'.

1
Any updates on this? - vivek nuna

1 Answers

0
votes

Better you should share the classes implementation for better understanding. I'm providing you code according to my understanding. You can use the similar code to solve your problem.

public class usu_titefol
{
    public e013agp e013agp { get; set; }
    [ForeignKey("codemp")]
    [Required]
    public int usu_grpcom { get; set; }
}