1
votes

I'm getting this error with Breeze when I try to access the metadata url:

http://localhost:1886/api/posts/metadata

Self referencing loop detected for property 'PreviousAttribute' with type 'System.Xml.Linq.XAttribute'. Path 'root.firstAttribute.nextAttribute.nextAttribute.nextAttribute.nextAttribute.nextAttribute.nextAttribute'. ExceptionType: "Newtonsoft.Json.JsonSerializationException"

My other URL is working and retrieving data from the database just fine

http://localhost:1886/api/Posts/posts

My post.cs has nothing that could be self referencing and looks like so

public class Post
{
    public int PostID { get; set; }
    public int UserID { get; set; }
    public string Title { get; set; }
    public string Description { get; set; }
}

My controller:

[BreezeController]
public class PostsController : ApiController
{
    readonly EFContextProvider<PostsDbContext> contextProvider = new EFContextProvider<PostsDbContext>();

    [HttpGet]
    public string Metadata()
    {
        return contextProvider.Metadata();
    }

    [HttpGet]
    public IEnumerable<Post> Posts()
    {
        var posts = contextProvider.Context.Posts;
        return posts;
    }
}

I'm stuck on Windows XP using Visual Studio 2010 and EF 4 and .net 4. Are there version issues with Breeze and any of those?

2

2 Answers

0
votes

The problem may be that Entity Framework generates proxy objects. Try turning these of

dbContext.Configuration.ProxyCreationEnabled = false;
0
votes

Something in my project must have become corrupt, because I started over with a clean HotTowel template and the problem magically went away