Simple powershell script to convert the Entity Framework mappings from EF6 to EF Core.
This script is a starting point to bulk convert the mappings from EF6 to the EF Core format.
Some additional manual work might be required, but it will be useful if you have a lot of entities to migrate.
- Make a backup of your mappings.
- Put the mappings to convert in this directory: "C:_Dev\Mappings".
- Run the script and the mappings in "C:_Dev\Mappings" will be modified to work with EF Core.
- HasRequired is becoming HasOne and you must add IsRequired to your mapping
- HasOptional is becoming HasOne (without adding IsRequired in this case)
Example:
.HasRequired(userAccount => userAccount.GlobalizationUserLanguage)
--> builder.HasOne(userAccount => userAccount.GlobalizationUserLanguage)
....
.IsRequired()
.HasOptional(calibrator => calibrator.Migration)
--> builder.HasOne(calibrator => calibrator.Migration)