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!
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!
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");
It's not possible to customize the foreign key constraint name with Data annotations
or Fluent API
.
There is some options that you can follow:
SqlServerMigrationSqlGenerator
from System.Data.Entity.SqlServer