In Entity Framework code-first, if you have a domain model like the following:
1 2 3 4 5 6 7 | public class Country { public int Id { get; set; } [Index] public string IsoCode { get; set; } } |
and want to create an index for a string property, when you execute update-database for your migration, you may end up with the following error: This usually happens when you use VARCHAR(max), which is the default column type when creating a string property in EF. To make…