David Keylock

David Keylock

  • 1.7k
  • 30
  • 1.6k

Entity Framework (Self-Tracking Entities)

Oct 30 2012 7:33 AM

I have added a Self-Tracking Entity Generator to my existing Entity Framework setup.

Now when I retrieve a World record from the database, for example

public class World
{
    public Guid Id { get; set; }
    public string Name { get; set; }
    public string Universe { get; set; }
    public EntityCollection<Country> Countries { get; set; }
}

which has a 1 to Many relationship to the table Country, the collection Countries is 0 and I know that in the database the records in the Country table exist.

By adding the Self-Tracking Entity Generator I have somehow destroyed the databases relationships.

Does anyone know how I can use a Self-Tracking Entity Generator but preserve the relationships?

Many thanks