Add migration
Add a migration for the new property
whenever me we make changes to the entities, we need to create a migration and apply it to the database so that they both are In Sync
create a migration
Let us create a migration for this new field as shown below
After this command has executed, we see that a new file has been created inside the migrations folder and the code in it looks like this
This is the code required to add the new column 2 hours students table in SQL Server database. Entity framework analyzed what has changed and then created suitable code for it all by itself!
Apply migration
the database is still not modified so let us apply the migration with the command below
Now run the application again
Any modifications to the entities require that we add a migration and apply it to the database similarly!
For production scenario, we can apply the changes (migration) using a different approach which we will discuss later!
Last updated