I have a post table and a tag table and bridge table PostTag.
Post 1 has 23 tags , meaning
post p= context.posts.where(p=>p.id=12);
p.tags.Count() =12;
Ok ,fine.
Now I added some new tags to tag table but i want to attach these tags to the same old post
so what i did,
- Post p= context.posts.where(p=.p.id=12);
- foreach(tag t in tags)
- {
- p.tags.add(t);
- }
- context.savechanges();
There is no error, but no output aswell , meaning still post has old tags and new tags are not added to the post.


Sachin SinghRank #66 · 26.2K reputationPosted Aug 5, 2020, 7:42 AM EDT
Varun SetiaRank #308 · 8.2K reputationPosted Aug 5, 2020, 5:13 AM EDT
Sachin SinghRank #66 · 26.2K reputationPosted Aug 5, 2020, 6:22 AM EDT
Varun SetiaRank #308 · 8.2K reputationPosted Aug 5, 2020, 6:54 AM EDT
Sachin SinghRank #66 · 26.2K reputationPosted Aug 5, 2020, 7:11 AM EDT
Varun SetiaRank #308 · 8.2K reputationPosted Aug 5, 2020, 7:41 AM EDT
Varun SetiaRank #308 · 8.2K reputationPosted Aug 5, 2020, 7:46 AM EDT
Sachin SinghRank #66 · 26.2K reputationPosted Aug 5, 2020, 5:08 AM EDT
Varun SetiaRank #308 · 8.2K reputationPosted Aug 5, 2020, 4:59 AM EDT