I have a simple Entity Framework Code First context for persisting events as they arrive from the bus. The context is :
public class MyContext : DbContext
{
public MyContext (DbConnection connection)
: base(connection, false)
{
Database.SetInitializer<MyContext>(null);
Configuration.AutoDetectChangesEnabled = true;
}
public DbSet<MyEvent> MyEvents { get; set; }
}
where MyEvent is
public class MyEvent
{
public int Id { get; set; }
public string Source { get; set; }
public string MessageId { get; set; }
public DateTime EventDate { get; set; }
}
Now, when I try to access the context.MyEvents collection I get a ReflectionTypeLoadException
Unable to load one or more of the requested types. Retrieve the LoaderExceptions property for more information.
with LoaderException
"Method 'ToCombinedRows' in type 'XXXX' from assembly 'YYYY' does not have an implementation."
Now this is really strange as the type XXXX is completely unrelated to the object being persisted and has no reason to have a method of this name.
All the objects are defined in the same assembly, and I am running from an integration test project, with references CopyLocal set to true. Does anyone know how to get my context to talk to the database?