Skip to content

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.

To make basic changes to the database (existing objects/tables)

  1. Update the database models in Trifolia.DB\Model
  2. Update Trifolia.DB\Model\DBModel.cs as appropriate to assign relationships
  3. 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
  4. Run “Update-Database” to update based on the changes made in code

Creating new objects/tables

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.

Clone this wiki locally