I get an InvalidOperationException "The sequence does not contain an inappropriate element" that occurs when I try to execute the following code. This is done during the initial setup of the database:
Global.migrationContext.SourceObjects.Add(sourceObject);
The source object is as follows:
DataMigrationMapping.SourceObject MigrationPasses null System.Collections.ObjectModel.ObservableCollection<DataMigrationMapping.MigrationPass> Name "COMP_CASE" string Notes "Complaint Case" string Schema "Wacka" string SourceElements null System.Collections.Generic.List<DataMigrationMapping.SourceElement> SourceObjectID 0 int
My dbContext looks like this:
public class MigrationContext : DbContext { public DbSet<SourceObject> SourceObjects {get; set;} public DbSet<SourceElement> SourceElements {get; set;} public DbSet<MigrationPass> MigrationPasses {get; set;} public DbSet<Entity> Entities {get; set;} public MigrationContext(string connectionString) : base(connectionString) { } public void Load() { SourceObjects.Load(); SourceElements.Load(); MigrationPasses.Load(); Entities.Load(); } }
An error started to appear after adding this property to the MigrationPass class:
public Entity TargetEntity { get; set; }
Which leads me to believe that something is wrong with my model coming from the Entity class. Perhaps something in common with this class is abstract. The entity class is as follows:
public abstract class Entity { public int EntityID { get; set; } public string Name { get; set; } public EntityType EntityType { get; set; } public string RefCode { get; set; } public Cardinality Cardinality { get; set; } protected ObservableCollection<Field> fields; [NotMapped] public ObservableCollection<Field> Fields { get { return fields; } } public void AddField(Field field) { fields.Add(field); } protected ObservableCollection<Entity> roles; [NotMapped] public ObservableCollection<Entity> Roles { get { return roles; } } public void AddRole(Entity role) { roles.Add(role); }
Any ideas on what might cause the error?
source share