I am trying to add an Entity Framework, first code, to an MVC application that was run with test data using a CTP4 preview.
I am currently getting this error:
The model supporting the SchedulerContext context has changed since the database was created. Either manually delete / update the database, or call Database.SetInitializer with an instance of IDatabaseInitializer. For example, the RecreateDatabaseIfModelChanges strategy will automatically delete and recreate the database and possibly sow it with new data.
I do not want to generate a database at all, since I already have a database. Therefore, I tried to add the following to the SchedulerContext constructor:
Database.SetInitializer<SchedulerContext>(new CreateDatabaseOnlyIfNotExists<SchedulerContext>());
which had no effect - I got the same error the next time. The error occurs when it executes a LINQ statement that accesses the database - the first one, I think.
Where should I put this statement or is this statement generally the answer to this problem?
Cynthia
source share