Sign Up

Sign Up to our social questions and Answers Engine to ask questions, answer people’s questions, and connect with other people.

Have an account? Sign In

Have an account? Sign In Now

Sign In

Login to our social questions & Answers Engine to ask questions answer people’s questions & connect with other people.

Sign Up Here

Forgot Password?

Don't have account, Sign Up Here

Forgot Password

Lost your password? Please enter your email address. You will receive a link and will create a new password via email.

Have an account? Sign In Now

You must login to ask a question.

Forgot Password?

Need An Account, Sign Up Here

Please briefly explain why you feel this question should be reported.

Please briefly explain why you feel this answer should be reported.

Please briefly explain why you feel this user should be reported.

Sign InSign Up

The Archive Base

The Archive Base Logo The Archive Base Logo

The Archive Base Navigation

  • SEARCH
  • Home
  • About Us
  • Blog
  • Contact Us
Search
Ask A Question

Mobile menu

Close
Ask a Question
  • Home
  • Add group
  • Groups page
  • Feed
  • User Profile
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Buy Points
  • Users
  • Help
  • Buy Theme
  • SEARCH
Home/ Questions/Q 7875265
In Process

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: June 3, 20262026-06-03T02:57:14+00:00 2026-06-03T02:57:14+00:00

I am using entity framework 4.3 with SQLite to make many-to-many relationship between entities.

  • 0

I am using entity framework 4.3 with SQLite to make many-to-many relationship between entities. But in runtime, Group.Parameters and Parameter.Groups collections are empty, until i manually adds them.

Entities are:

public class Group
{
    public Group()
    {
        Parameters = new ObservableCollection<Parameter>();
    }
    public Int64 Id { get; set; }
    public string Name { get; set; }
    public ObservableCollection<Parameter> Parameters { get; set; }
}

public class Parameter
{
    public Parameter()
    {
        Groups = new ObservableCollection<Group>();
    }

    public Int64 Id { get; set; }
    public string Name { get; set; }
    public ObservableCollection<Group> Groups { get; set; }
}

In OnModelCreating:

modelBuilder.Entity<Group>().HasMany(g => g.Parameters).WithMany(p => p.Groups).Map(c =>
{
    c.MapLeftKey("GroupId");
    c.MapRightKey("ParameterId");
    c.ToTable("Groups_has_Parameters");
});

sql for creating tables:

create table if not exists Parameters
(
    Id INTEGER PRIMARY KEY AUTOINCREMENT NOT NULL,
    Name TEXT NOT NULL
);

create table if not exists Groups
(
    Id INTEGER PRIMARY KEY AUTOINCREMENT NOT NULL,
    Name TEXT NOT NULL
);
create table if not exists Groups_has_Parameters
(
    GroupId INTEGER NOT NULL,
    ParameterId INTEGER NOT NULL,
    PRIMARY KEY (GroupId, ParameterId),

    FOREIGN KEY (GroupId) REFERENCES Groups(Id),
    FOREIGN KEY (ParameterId) REFERENCES Parameters(Id)
);
  • 1 1 Answer
  • 0 Views
  • 0 Followers
  • 0
Share
  • Facebook
  • Report

Leave an answer
Cancel reply

You must login to add an answer.

Forgot Password?

Need An Account, Sign Up Here

1 Answer

  • Voted
  • Oldest
  • Recent
  • Random
  1. Editorial Team
    Editorial Team
    2026-06-03T02:57:15+00:00Added an answer on June 3, 2026 at 2:57 am

    To enable lazy loading make your navigation properties virtual. For example:

    public virtual ObservableCollection<Parameter> Parameters { get; set; } 
    

    This way EF will automatically load the collection from the database the first time it is accessed.

    If you don’t want to make them virtual or have lazy loading then you can explicitly load the collection at any time using something like:

    context.Entry(group).Collection(g => g.Parameters).Load();
    

    Or, as Gaga suggested, you can eagerly load the collection when you do the initial query of the database using Inlcude:

    context.Groups.Include(g => g.Parameters);
    
    • 0
    • Reply
    • Share
      Share
      • Share on Facebook
      • Share on Twitter
      • Share on LinkedIn
      • Share on WhatsApp
      • Report

Sidebar

Related Questions

I'm using Entity Framework 4 and have a one-to-many relationship between a parent and
I'm currently using Entity Framework and am running into this issue: The relationship between
I'm using Entity Framework 4.1 and trying to create a one-to-many relationship. In my
I'm tring to insert some records into my Sqlite database using the Entity Framework.
I'm using Entity Framework Code First v 4.3.0 I have a two entities with
Using Entity Framework 4.1 code first and POCO entities in MVC3; I would like
I'm using the Entity Framework (.NET 4.0) with SQLite as the underlying database and
I'm having a problem with primary keys in Entity Framework when using SQLite. SQLite
I am following the article Using SQLite Embedded Database with Entity Framework and Linq-to-SQL
I am using Entity Framework. One of my Entities (MyEntity) has a dependency on

Explore

  • Home
  • Add group
  • Groups page
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Users
  • Help
  • SEARCH

Footer

© 2021 The Archive Base. All Rights Reserved
With Love by The Archive Base

Insert/edit link

Enter the destination URL

Or link to existing content

    No search term specified. Showing recent items. Search or use up and down arrow keys to select an item.