dotnet / dotnet/EntityFramework.Docs

Document conventions for creating EF6 constraint names

Open
#4,314 3 comments 0 reactions 0 assignees View on GitHub
area-migrations area-value-conversions
Dominant language
Mermaid
Stars
1.7k
Forks
2k
Avg merge
7d 23h
Merged PRs (30d)
16

Description

Hi! I'm trying to port Entity Framework to EF core. My steps are as follows (if you have suggestions or tips, please let them hear!):

1. New project in solution for containing EF Core code-first configuration & migrations
2. Migrate all the Entity Framework configurations to the new EF Core style
3. Apply EF core migrations to local database next to the existing Entity Framework database
4. Use SQL Server Schema Comparer to make sure all table-, constraint- and other names are equal to Entity Framework database
4.1. Not equal? Make changes in the EF Core configuration and execute step 3 again.
4.2. Equal? Yeah, next step!
5. Point EF Core project to Entity Framework database and remove legacy '__MigrationHistory' table
6. Remove Entity Framework database
7. Port is finished!

So, I'm currently at step 3/4. I've also noticed that the constraints name of primary and foreign keys are changed in the versions:

EF Core:
`(..) CONSTRAINT [FK_Entity_ReferringEntity_Id] FOREIGN KEY ([ReferreringEntityId]) REFERENCES [dbo].[ReferringEntity] ([Id]) (..)`

Entity Framework:
`(..) CONSTRAINT [FK_dbo.Entity_dbo.ReferringEntity_Id] FOREIGN KEY ([ReferreringEntityId]) REFERENCES [dbo].[ReferringEntity] ([Id]) (..)`

As you can see the scheme ('dbo.') is removed from the constraint name in EF Core. Was this a change within EF Core and is there a way to get it back?

Contributor guide

Open the contributing guide

Assessment

This issue has not been assessed yet.

Get new issues in your inbox

A short digest of beginner-friendly GitHub issues.