Preload repository ignoring some foreign keys

56 views Asked by At

We're using Effort to write unit tests against an EF6 model. It works fine when doing so, but setting up the initial state of the repository can be difficult. For example (and leaving a lot of the relationships out), we might be testing code that uses a booking object. That booking has a contract record which in turn has a customer record. The customer record has an office record which links to a location record, which links to a country record. The customer record also links to a language record, and so on. There are dozens of records that need to be in place before you can write the test, despite the test not visiting the majority of them. As well as the effort to set up the repository, this has an impact on the start up time of each test. Is there a way to initialise Effort without creating the records we don't actually need, by relaxing the foreign key constraints when seeding the data?

0

There are 0 answers