Reputation: 2391
Entity Framework Core doesn't allow me to name different migrations with same name. Although the names will still be different, because the timestamp is always different. The error is:
The name '_' is used by an existing migration.
Previous version of EF (.NET Framework) allowed to do this.
Upvotes: 1
Views: 908
Reputation: 1662
Although the names will still be different, because the timestamp is always different
This is not entirely correct. Although the name of the migration uses a timestamp in it, the name of the generated migration class itself would be the name without any timestamp.
This name is generated inside the CSharpMigrationsGenerator class using ICSharpHelper.Identifier. An instance implementing this interface is injected using dependency injection which does sound to possess ability of overriding implementation with your own code, however I do not see this happening using the out of the box command line tools, you might need to re-invent your own migrations tool or do that from your application code.
And even if you do manage to overcome this part, there are other internal stuff you would need to handle. For instance, IMigrationsAssembly.Migrations also holds the names of the migrations without the timestamp part, therefore you would still need to adjust the names so that they are unique, because the dictionary simply does not allow duplicate keys.
Summa summarum, it might be possible, but doesn't sound to be worth the effort with the current version of EF Core.
Upvotes: 1