C
C#2y 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
Tvde12y 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
bookuha2y 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
Tvde12y ago
have you tried anything yet? Any errors?
bookuha
bookuha2y ago
Yes, I did. But I found it wrong. But seemingly this actually is a solution:
bookuha
bookuha2y 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
bookuha2y ago
Or [InverseProperty] attribute must be used I guess
bookuha
bookuha2y ago
yeees I feel so happy because finally solution is here @Tvde1 thank you!
Tvde1
Tvde12y 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
bookuha2y ago
🍎🍐🍋 yes! I was not aware of multiple relationships between two entities
Want results from more Discord servers?
Add your server
More Posts