I have a code first EF Model with a simple one(PartDetails)-to-many(Parts) relationship.
While the system is offline the lookup (PartDetails) table is purged and re-populated by external job, violating the constraint.
modelBuilder.Entity<Part>().HasOptional(e => e.PartDetails)
.WithMany()
.HasForeignKey(k => k.PartDetailsId);
I have tried .Map and other variants but all create the DB constraint.
How can I prevent EF from creating the DB FK constraint using the fluent API?
I understand this may not be the best architectural approach but I'm stuck with it. If I can't find a solution to do this with the Fluent API I will manually drop the constraint in a migration script or drop and re-add the constraint during the purge job.