1

I have the following models:

class Item
{
    public ICollection<string> GroupIds { get; set; }

    // Introduced for EF only
    public ICollection<Group> Groups { get; set; }
}

class Group
{
    public ICollection<string> ItemIds { get; set; }

    // Introduced for EF only
    public ICollection<Item> Items { get; set; }
}

class Store
{
    public ICollection<Item> Items { get; set; }

    public ICollection<Group> Groups { get; set; }
}

Store contains all Items and all Groups, but every Item may be related with one or multiple Group and every Group may be related with one or multiple Item.

How I can configure many-to-many relationship between Item and Group to load only GroupIds and ItemIds, but not objects itself?

4
  • Duplicate, which means: you can't make EF to use the string[] properties and the other array properties should be ICollection<T>. Commented May 27, 2019 at 20:00
  • Well, that doesn't matter. I can use ICollection<string> and ICollection<Item>, ICollection<Group>, question still be the same Commented May 28, 2019 at 6:56
  • I'm asked not about how to configure many-to-many relationship, but how to have IDs only without loading objects themselves Commented May 28, 2019 at 6:58
  • OK, reopened, but then I'm not sure what you're asking. What I do know is that you can't map your current model with EF. Commented May 28, 2019 at 7:35

0

Your Answer

By clicking “Post Your Answer”, 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.