DatabaseInitializer and ef6 not working - due to only having Async tasks?

Feb 3, 2016 at 11:04 PM
I'm trying to use this with the ef6 extensions. I'm using EF 6.1. Before starting my UI part of the project, I'm trying to create and run some unit tests.
Database initialization using the database initializers are failing with the error:
The context cannot be used while the model is being created. This exception may be thrown if the context is used inside the OnModelCreating method or if the same context instance is accessed by multiple threads concurrently. Note that instance members of DbContext and related classes are not guaranteed to be thread safe.

Here's my code ...
Database.SetInitializer<HolosEntityContext>(new DropCreateDatabaseAlways<HolosEntityContext>());

var context = new HolosEntityContext();

IQueryable<SurgeryCenter> set = context.SurgeryCenters;

var list = set.ToList(); //exception is thrown here ...

I'm assuming this is because all of the operations seem to be Async - how do I initialize the database using the initializers if I'm using your Context object?
Feb 3, 2016 at 11:48 PM
Never mind ....

It was my own farkled coding. The first line was incorrect, and should have been:
        Database.SetInitializer<HolosEntityContext>(new HolosEntitySeedInitializer());
where HolosEntitySeedInitializer is derived from one of the EF database initializers. After correcting, everything is working.