Joellao
Joellao
CC#
Created by Joellao on 3/20/2024 in #help
Saving state in time - "snapshot"
Any suggestion on this one?
2 replies
CC#
Created by Joellao on 2/4/2024 in #help
EF Migrations 101
The naming I mean
27 replies
CC#
Created by Joellao on 2/4/2024 in #help
EF Migrations 101
Or something similar to this one
27 replies
CC#
Created by Joellao on 2/4/2024 in #help
EF Migrations 101
And in the UserEntity I had the Friends collection with UserEntity as a type and FriendRelationships with the middleclass
27 replies
CC#
Created by Joellao on 2/4/2024 in #help
EF Migrations 101
FriendshipReceiver and that was it
27 replies
CC#
Created by Joellao on 2/4/2024 in #help
EF Migrations 101
FriendshipSender with FriendshipSenderId
27 replies
CC#
Created by Joellao on 2/4/2024 in #help
EF Migrations 101
But qutie easy
27 replies
CC#
Created by Joellao on 2/4/2024 in #help
EF Migrations 101
Don't have it anymore since I reverted back the branch
27 replies
CC#
Created by Joellao on 2/4/2024 in #help
EF Migrations 101
UserEntity is the users one. FriendshipEntity for the middle
27 replies
CC#
Created by Joellao on 2/4/2024 in #help
EF Migrations 101
I'm also using the Creator and CreatorId thingy explicitly
27 replies
CC#
Created by Joellao on 2/4/2024 in #help
EF Migrations 101
Yeah I also used the middle entity for the friendship also, but when doing that it created the new Column called UserEntityId inside the Users table. It expects to be filled somehow but I don't have that relationship.
27 replies
CC#
Created by Joellao on 2/4/2024 in #help
EF Migrations 101
But still I'm getting some passive trauma I guess :kekw:
27 replies
CC#
Created by Joellao on 2/4/2024 in #help
EF Migrations 101
Now I reverted everything back, in the meantime have lost several migrations, maybe like 5, because of these problems. But whatever, it's a new project so whatever if I don't have the full history of migrations
27 replies
CC#
Created by Joellao on 2/4/2024 in #help
EF Migrations 101
All my problems started with a ManyToMany relationship. User and Groups. I have UserEntityu and GroupsEntity. I also created a middle Entity to map this called UserGroupEntity. That seems quite simple. The first problem with this arose with having in the UserEntity a CreatedGroups and then a ParticipatingGroups collections. I wanted also to avoid having the middle table relationship in the two entities. Finally I made it work with this piece of horror
modelBuilder
.Entity<GroupEntity>()
.HasOne(p => p.Creator)
.WithMany(u => u.Groups)
.HasForeignKey(p => p.CreatorId);

modelBuilder
.Entity<GroupEntity>()
.HasMany(e => e.Members)
.WithMany(e => e.Participant)
.UsingEntity<UserGroupEntity>(
j => j
.HasOne(pt => pt.User)
.WithMany(t => t.ParticipatingGroups)
.HasForeignKey(pt => pt.UserId),
j => j
.HasOne(pt => pt.GroupEntity)
.WithMany(p => p.Memberships)
.HasForeignKey(pt => pt.GroupId));
modelBuilder
.Entity<GroupEntity>()
.HasOne(p => p.Creator)
.WithMany(u => u.Groups)
.HasForeignKey(p => p.CreatorId);

modelBuilder
.Entity<GroupEntity>()
.HasMany(e => e.Members)
.WithMany(e => e.Participant)
.UsingEntity<UserGroupEntity>(
j => j
.HasOne(pt => pt.User)
.WithMany(t => t.ParticipatingGroups)
.HasForeignKey(pt => pt.UserId),
j => j
.HasOne(pt => pt.GroupEntity)
.WithMany(p => p.Memberships)
.HasForeignKey(pt => pt.GroupId));
Today I wanted to create a Friendship relationship, so a List of UserEntity in the UserEntity should make the trick. Nope, it doesn't work because the UserId is already in a relationship and can only be once (or something similar was the error, don't have it under my hands right now). So back to manually do the relationship by hand. Everything compiled, the database updated, but now there is a new column in the Users table that is not needed, and of course I don't have that mapping anywhere in the code and that's driving me crazy
27 replies
CC#
Created by Joellao on 1/24/2024 in #help
✅ Database Scaffolding going wrong.
Solved this by introducint the UserGroupEntity in the GroupEntity and UserEntity. Wanted to avoid that, but no clues
23 replies
CC#
Created by Joellao on 1/24/2024 in #help
✅ Database Scaffolding going wrong.
That's valid also for Members
23 replies
CC#
Created by Joellao on 1/24/2024 in #help
✅ Database Scaffolding going wrong.
Sorry for the late reply. I appreciate your suggestions, since I have nothing on my hand on my own, I can't go after you because you make suggestions. I can't do the relationships because ParticipatingGroups is not of type UserGroupEntity
23 replies
CC#
Created by Joellao on 1/24/2024 in #help
✅ Database Scaffolding going wrong.
Yessir
23 replies
CC#
Created by Joellao on 1/24/2024 in #help
✅ Database Scaffolding going wrong.
Yes
23 replies
CC#
Created by Joellao on 1/24/2024 in #help
✅ Database Scaffolding going wrong.
Yeah, but it's the same, didn't copy it correctly
23 replies