I had to work further from a ex collega. So I run the asp.net solution without database. and it created a database. I think this is Code First or Code First Migrations.
Then I tried some tests in de UI and get this message:
An exception of type 'System.NotSupportedException' occurred in EntityFramework.dll but was not handled in user code
Additional information: Model compatibility cannot be checked because the database does not contain model metadata. Model compatibility can only be checked for databases created using Code First or Code First Migrations.
This is the code where de message come from.
public class TemInitializer : System.Data.Entity.DropCreateDatabaseIfModelChanges<ApplicationDbContext>
{
public override void InitializeDatabase(ApplicationDbContext context)
{
base.InitializeDatabase(context);
}
}
Can anybody tell me how to solve this or where i need to look?
The DropCreateDatabaseIfModelChanges
initializer drops and recreates the database if the database schema no longer matches the classes in your code. It determines "if model changes" by looking at your classes and by looking at a table called _MigrationHistory
in the database. If there is no such table, it throws the exception in the question.
So to solve this, you can:
DropCreateDatabaseAlways
) or_MigrationHistory
table in your database, by enabling Entity Framework code first migrations.