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 8300895
In Process

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: June 8, 20262026-06-08T16:43:27+00:00 2026-06-08T16:43:27+00:00

I have a model like public class User { [Key] public long UserId {

  • 0

I have a model like

public class User
{
    [Key]
    public long UserId { get; set; }

    [Required]
    public String Nickname { get; set; }

    public virtual ICollection<Group> Memberships { get; set; }
}

public class Group
{
    [Key]
    public long GroupId { get; set; }

    [Required]
    public String Name { get; set; }

    public virtual ICollection<User> Members { get; set; }
}

public class DataContext : DbContext
{
    public DbSet<User> Users { get; set; }
    public DbSet<Group> Groups { get; set; }

    public DataContext()
    {
        Configuration.LazyLoadingEnabled = true;
    }

    protected override void OnModelCreating(DbModelBuilder modelBuilder)
    {
        modelBuilder.Entity<User>()
        .HasMany(u => u.Memberships)
        .WithMany(t => t.Members)
        .Map(x =>
        {
            x.MapLeftKey("UserId");
            x.MapRightKey("GroupId");
            x.ToTable("GroupMembers");
        });
    }
}

All goes fine when accessing the entities using a test console application, but I need to have this through a WCF service, here I got this exception:

Failed to invoke the service. Possible causes: The service is offline or inaccessible; the client-side configuration does not match the
proxy; the existing proxy is invalid. Refer to the stack trace for
more detail. You can try to recover by starting a new proxy, restoring
to default configuration, or refreshing the service

The only way I found to have this working is, removing the navigator in one of the entities, because having the navigators in both sides causes a infinite looping.

Is there a way to have this working without removing the navigators?

  • 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-08T16:43:31+00:00Added an answer on June 8, 2026 at 4:43 pm

    There are two issues if you try to use WCF:

    • First issue: Do you want to return related entities as well? Always turn off lazy loading when working with WCF / serialization and make sure that you manually use Include for relations you really want to return. Otherwise lazy loading will load all relation in the object graph. Moreover depending on the way how your service handles context’s life cycle, the lazy loading can happen when the context is already disposed.
    • You must tell serializer about the circular reference or remove the circular reference. WCF by default uses DataContractSerializer. To remove the circular reference you can mark one of those navigation properties with IgnoreDataMember attribute or you can simply tell serializer about the circular reference by marking all entities with DataContract(IsReference = true) attribute and all member properties which should be serialized with DataMember attribute.
    • 0
    • Reply
    • Share
      Share
      • Share on Facebook
      • Share on Twitter
      • Share on LinkedIn
      • Share on WhatsApp
      • Report

Sidebar

Related Questions

I have a model like public class User { [Key] public long UserId {
I have a model like this defined... public class Product{ private long timestamp; //
I have the following code: modelBuilder.Entity<User>().HasMany(x => x.Items).WithRequired(); The model looks like public class
I have a model that looks like this: public class UserAdminEditViewModel { public User
I have a model that looks like this: public class Book { public string
I have a model class like following public class ProductModel { string ProductName {
I have a model that looks something like this public class User { public
I'm using MVC3 and I have a model like this: public class Foo {
I have a recursive model like this: public class Node { public int Id
I have a model that looks like: [Serializable] public class TemplatePageModel { public PageModel

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.