Click here to Skip to main content
15,843,498 members
Please Sign up or sign in to vote.
0.00/5 (No votes)
See more:
Im using DDD in my project and I have an entity which belong to two bounded contexts with different properties each one. Both bounded contexts add records by this entity.
How can I configure these two classes to map to same table by fluent Api?

What I have tried:

I have try that solution

entity framework core - EFCore Map 2 entities to same table - Stack Overflow[^]

but its working only if add a new record from the first bounded context. When Im trying to add from the second Im getting this error:
The value 'Id' of is unknown when attempting to save changes. This is because the property is also part of a foreign key for which the principal entity in the relationship is not known.
Updated 10-Jul-21 2:46am
Manos Kanellopoulos 7-Jul-21 12:37pm    
Any idea plz?
Gerry Schmitz 7-Jul-21 15:57pm    
Manos Kanellopoulos 7-Jul-21 16:03pm    
Hi Gerry! If I set two classes to same table will thrown an exception it says that already a class mapping to the table
Manos Kanellopoulos 7-Jul-21 16:04pm    
Its needs something to understand that those classes are mapping to the same table
Gerry Schmitz 8-Jul-21 12:45pm

1 solution

Try using the mapped entity as a base class for two derived entities.
Share this answer

This content, along with any associated source code and files, is licensed under The Code Project Open License (CPOL)

CodeProject, 20 Bay Street, 11th Floor Toronto, Ontario, Canada M5J 2N8 +1 (416) 849-8900