0

Is there a way to relate two entities just in EF Core and not in the database? I need to relate two table in EF Core not in Database Because if I apply all the relationships in the database, a lot of relationships will be created for that table and it will slow down.

Alifvar
  • 139
  • 11
  • Does this answer your question? [EF Core and Multiple Databases](https://stackoverflow.com/questions/52157196/ef-core-and-multiple-databases) – Progman May 15 '22 at 08:47
  • No I want to Relate two Entity in Efcore and remove relation in database please read carefully. I just gave an example but my entities are in same database – Alifvar May 15 '22 at 08:53
  • 1
    Well no. As in you can relate two entities, but if you relate them in EFCore they are related to the same database. That's the whole point of a relational mapping framework like EFCore. Solution: relate them via another means than EFCore. – JHBonarius May 15 '22 at 09:08
  • @Alifvar You said in the question that these entities are in two different database, but in the comment you said that these entities are in the same database. Which one is it? – Progman May 15 '22 at 09:15
  • @Progman you're right but I think that the solution is the same but now I figured out that solution is different . – Alifvar May 15 '22 at 10:02
  • If you found the solution, like you say, please delete the question. If you still have a question, please rewrite the whole question into something consistent. Because now it's all very confusing. Read the help section of SO for tips on writing a good question. – JHBonarius May 15 '22 at 10:19
  • Please clarify your specific problem or provide additional details to highlight exactly what you need. As it's currently written, it's hard to tell exactly what you're asking. – Community May 16 '22 at 07:48
  • @Community why question is clear. I need to relate two table in EF Core not in Database Because if I apply all the relationships in the database, a lot of relationships will be created for that table and it will slow down. – Alifvar May 16 '22 at 10:51
  • @Alifvar, do you want to have an **unmapped navigational property**? if so `[NotMapped]` might be the attribute you need, see [docs](https://entityframework.net/not-mapped) and see [relevant qa](https://stackoverflow.com/questions/59841113/ef-core-notmapped-getter-with-logic-and-using-navigation-properties-lazy-loadi). – Bagus Tesa May 16 '22 at 11:30
  • @Bagus kind of that but not exactly i want to custom map EF Core to get related data in other word i want to relate Entities in EF Core. – Alifvar May 16 '22 at 13:08
  • well, if you want a **custom relationship mapping**, then EF Core is the wrong tool in the shed as JHBonarius said. how do you know if two object related or not? where the relationships are stored? fyi, asking for a library or tools most of the time is not well regarded. – Bagus Tesa May 16 '22 at 13:12

0 Answers0