C
C#3y ago
bookuha

Many-To-Many with same fields of same type

I have a tables Users and Transactions. I want to make my Transactions store two entities: sender and reciever (Both are users) How do I configure with Entity Framework Fluent API?
10 Replies
Tvde1
Tvde13y ago
what have you tried so far? 😁 Any reason you think
class Transaction
{
public User Sender { get; set; }
public User Receiver { get; set; }
}
class Transaction
{
public User Sender { get; set; }
public User Receiver { get; set; }
}
wouldn't work?
bookuha
bookuhaOP3y ago
How do I configure this with FluentAPI? Like, I need to specify that it is a joining table And I can reference a transaction by User object and vise versa Thats the problem 😦 I dont even know how to google it lol
Tvde1
Tvde13y ago
have you tried anything yet? Any errors?
bookuha
bookuhaOP3y ago
Yes, I did. But I found it wrong. But seemingly this actually is a solution:
bookuha
bookuhaOP3y ago
Stack Overflow
Adding a second one-to-one relationship with the same table in enti...
I am doing code-first entity framework design. I have a table, Account, which has a property, Supervisor: public class Account { public int Id { get; set; } public Account Supervisor { get; s...
bookuha
bookuhaOP3y ago
Or [InverseProperty] attribute must be used I guess
bookuha
bookuhaOP3y ago
yeees I feel so happy because finally solution is here @Tvde1 thank you!
Tvde1
Tvde13y ago
https://learn.microsoft.com/en-us/ef/core/modeling/relationships This article also contains all you need to know about EF relationships
Relationships - EF Core
How to configure relationships between entity types when using Entity Framework Core
bookuha
bookuhaOP3y ago
🍎🍐🍋 yes! I was not aware of multiple relationships between two entities
Want results from more Discord servers?
Add your server