User-271186128 posted
Hi Izeko2004,
I then create a new model with some test properties, and the create a new migration as above with out the 'Enable-Migrations' part.
I get no errors but my new migration is empty. Why is this. What have i missed?
If you want to add a new model, after adding the model class file, you need to add the DbSet properties in your DBContext class.
like this sample: after adding the Student class, add the DbSet property in the SchoolContext
public class SchoolContext: DbContext
{
public SchoolContext(): base()
{
}
public DbSet<Student> Students { get; set; }
public DbSet<Grade> Grades { get; set; }
}
Then, using Add-Migration command to generate a migration class, finally, update the database using the Update-Database command.
More details about EF Code First, please refer to the following links:
http://www.entityframeworktutorial.net/code-first/code-based-migration-in-code-first.aspx
http://www.entityframeworktutorial.net/code-first/simple-code-first-example.aspx
Best regards,
Dillion