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.