I must admin this is kind of funny even though I think I understand why :) I created a UnitTest to add a blog entry to try Alex suggestion about my inheritance problems. Now I come across another one.
[TestMethod]
public void UserCanAddBlogEntry()
{
var context = new EntityContext(Options.LazyLoading);
var user = (from u in context.Users
.Include("Blog.BlogEntries")
where u.Id == 1
select u).FirstOrDefault();
BlogEntry entry = new BlogEntry();
entry.Header = "Test Entry";
entry.Text = "Test Text blah blah blah";
entry.CreatedAt = DateTime.Now;
entry.Blog = user.Blog;
user.Blog.BlogEntries.Add(entry);
context.SaveChanges();
Assert.IsTrue(user.Blog.BlogEntries.Count > 0);
}
Causes the exception:
Failed UserCanAddBlogEntry Zirzle.UnitTests Test method UserCanAddBlogEntry threw exception: System.InvalidOperationException: Invalid relationship fixup detected in the navigation property 'User' of the entity of the type 'Profile'.
Not sure what is wrong with this picture. If I add .Include("Profile") in the get query then save changes doesnt complain any more. I tried adding a 0.1 relation end for profile but that didn't work out either. Any suggestions? I suppose stack overflows personal EF expert might have an explanation :)