-
Notifications
You must be signed in to change notification settings - Fork 9
Database
Sean McIlvenna edited this page Mar 1, 2017
·
3 revisions
Updating the database (adding/removing columns) is a matter of running “Update-Database” from the VS Package Manager console, targeting the Trifolia.DB project (screenshot below). Alternatively, you can use migrate.exe that is packaged with EntityFramework to execute the migrations.
- General Documentation: https://msdn.microsoft.com/en-us/library/jj591621(v=vs.113).aspx
- Update-Database documentation: https://coding.abel.nu/2012/03/ef-migrations-command-reference/
- migrate.exe documentation: https://msdn.microsoft.com/en-us/library/jj618307(v=vs.113).aspx
- Update the database models in Trifolia.DB\Model
- Update Trifolia.DB\Model\DBModel.cs as appropriate to assign relationships
- Run “Add-Migration ” in the package manager console (again, targeting the “Trifolia.DB” project) to generate migration scripts that are used to update the database
- Run “Update-Database” to update based on the changes made in code
A slightly different step is required to add in an entirely new table/object… You need to modify the Trifolia.DB.IObjectRepository interface so that it includes the new object. IObjectRepository is what we pass around from class to class, but it is not maintained automatically by EntityFramework. Because the interface changes, the MockObjectRepository class in the Trifolia.Test project will need to be updated as well.