Exchanged Foreign Key on Entity Framework Code First From data base

Thiago Sapucaia

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'.

vivek nuna

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; }
}

Collected from the Internet

Please contact [email protected] to delete if infringement.

edited at
0

Comments

0 comments
Login to comment

Related

From Dev

Entity Framework - Code first - Data annotations - Unnecessary foreign key columns

From Dev

Entity Framework Code First Foreign Key issue

From Dev

Entity Framework Code First Foreign Key issue

From Dev

Foreign Key in Code First Entity Framework

From Dev

Entity Framework: Foreign Key in code first

From Dev

Can I create a bidirectional foreign key relationship using Entity Framework Code First data annotations?

From Dev

Defining multiple Foreign Key for the Same table in Entity Framework Code First

From Dev

Entity Framework Code First Foreign Key adding Index as well

From Dev

Entity Framework 6 Code First Foreign Key Without Corresponding Properties

From Dev

Entity Framework Code First and Firebird - Foreign Key name issue

From Dev

Entity Framework Code first adds unwanted foreign key column

From Dev

Multiple Foreign Key for Same table in Entity Framework Code First

From Dev

Get foreign key value using Entity Framework code first

From Dev

Entity Framework one to optional foreign key code first fluent mapping

From Dev

Entity framework code first cant create primary and foreign key relationship

From Dev

Entity framework code first, get access to foreign key value

From Dev

Entity framework code first, custom foreign key name for inheritance

From Dev

How to specify a foreign key with code-first Entity Framework

From Dev

Entity Framework retrieve data from table with foreign key

From Dev

Entity framework sharing foreign key in base class

From Dev

Code First entity framework and foreign keys

From Dev

Entity Framework Code First initializing foreign keys

From Dev

Code first foreign key association MVC Entity

From Dev

Include foreign key in composite primary key in Code-First Entity Framework

From Dev

Entity Framework Code First from database not adding Key attribute

From Dev

How do I create multiple 1:1 foreign key relationships in Entity Framework 6 Code First?

From Dev

Entity Framework 6 multiple table to one foreign key relationship code first

From Dev

Entity Framework, Code First: How can i make a Foreign Key Not-Nullable

From Dev

Defining Self Referencing Foreign-Key-Relationship Using Entity Framework 7 Code First

Related Related

  1. 1

    Entity Framework - Code first - Data annotations - Unnecessary foreign key columns

  2. 2

    Entity Framework Code First Foreign Key issue

  3. 3

    Entity Framework Code First Foreign Key issue

  4. 4

    Foreign Key in Code First Entity Framework

  5. 5

    Entity Framework: Foreign Key in code first

  6. 6

    Can I create a bidirectional foreign key relationship using Entity Framework Code First data annotations?

  7. 7

    Defining multiple Foreign Key for the Same table in Entity Framework Code First

  8. 8

    Entity Framework Code First Foreign Key adding Index as well

  9. 9

    Entity Framework 6 Code First Foreign Key Without Corresponding Properties

  10. 10

    Entity Framework Code First and Firebird - Foreign Key name issue

  11. 11

    Entity Framework Code first adds unwanted foreign key column

  12. 12

    Multiple Foreign Key for Same table in Entity Framework Code First

  13. 13

    Get foreign key value using Entity Framework code first

  14. 14

    Entity Framework one to optional foreign key code first fluent mapping

  15. 15

    Entity framework code first cant create primary and foreign key relationship

  16. 16

    Entity framework code first, get access to foreign key value

  17. 17

    Entity framework code first, custom foreign key name for inheritance

  18. 18

    How to specify a foreign key with code-first Entity Framework

  19. 19

    Entity Framework retrieve data from table with foreign key

  20. 20

    Entity framework sharing foreign key in base class

  21. 21

    Code First entity framework and foreign keys

  22. 22

    Entity Framework Code First initializing foreign keys

  23. 23

    Code first foreign key association MVC Entity

  24. 24

    Include foreign key in composite primary key in Code-First Entity Framework

  25. 25

    Entity Framework Code First from database not adding Key attribute

  26. 26

    How do I create multiple 1:1 foreign key relationships in Entity Framework 6 Code First?

  27. 27

    Entity Framework 6 multiple table to one foreign key relationship code first

  28. 28

    Entity Framework, Code First: How can i make a Foreign Key Not-Nullable

  29. 29

    Defining Self Referencing Foreign-Key-Relationship Using Entity Framework 7 Code First

HotTag

Archive