Here's a basic example from the official .NET documentation for a many-to-many relationship using EF and .NET:

public class Post
{
    public int Id { get; set; }
    public List<Tag> Tags { get; } = [];
}

public class Tag
{
    public int Id { get; set; }
    public List<Post> Posts { get; } = [];
}

The Tags and Posts do not have a set. The join table only exists in the database, and there is, supposedly, no need to create an entity.

My question is: how do I set the value?

Thanks

3 Replies 3

What do you mean by "how do I set the value?" Which value? And by "set" do you mean a DbSet<Post> and DbSet<Tag>?

Yes, how do I set the value of public List Tags { get; } = []; and public List Posts { get; } = []; while those two do not have the set; There is something I don't get in the .net example in the documentation

This should be a regular question, not a discussion. But note that there are numerous existing questions and answers on this topic. Please try to find these first.

Your Reply

By clicking “Post Your Reply”, you agree to our terms of service and acknowledge you have read our privacy policy.

Start asking to get answers

Find the answer to your question by asking.

Ask question

Explore related questions

See similar questions with these tags.