Entity Framework Primary/Foreign constraint name

constraints ef-code-first ef-migrations entity-framework entity-framework-6

Question

Is there any way to rename a primary/foreign key constraint name through either data annotations or fluent API?

I'm not talking about the property/column name. The constraint name. I did some search and didn't find any solutions yet.

Please help!

1
0
11/12/2015 6:03:35 AM

Popular Answer

with .HasConstraintName like you can see in the underlying example

entity.HasOne(d => d.Director)
                    .WithMany(p => p.Movie)
                    .HasForeignKey(d => d.DirectorId)
                    .OnDelete(DeleteBehavior.ClientSetNull)
                    .HasConstraintName("FK_Movie_Person");
1
6/20/2018 8:24:25 PM


Related Questions





Related

Licensed under: CC-BY-SA with attribution
Not affiliated with Stack Overflow
Licensed under: CC-BY-SA with attribution
Not affiliated with Stack Overflow