1

I am trying to write integration tests with EF6. For this, I am using my own database initializer derived from DropCreateDatabaseAlways. In overridden Seed method, I create my entities. All is fine except that while saving context I get

----> System.Data.SqlClient.SqlException : The INSERT statement conflicted with the FOREIGN KEY constraint

It is irrelevant for my test to fully initialize my entities. Is there any way to programmatically disable constraints checks during integration tests with Entity Framework run?

Oleksandr Nechai
  • 1,811
  • 16
  • 27
  • 1
    The real question is "disable constraints checking in a database". Yes, get rid of your foreign keys, unique indexes etc... Good idea? Probably not. – spender Oct 15 '15 at 09:22
  • 2
    http://stackoverflow.com/questions/737115/turn-off-constraints-temporarily-ms-sql – spender Oct 15 '15 at 09:28

0 Answers0