I decided to change my blogging style a little bit. Instead of writing lengthy blog posts in a more systematic way I want to write things about all the different kinds of issue I got when building stuff and learning new things. I am very experienced in some areas but new on many more areas so the issues I got might be very basic and simple. I think that it is useful to just record it for myself and also for other people since they might get into the same situation.

I just started using entity framework 6.1.1 and tried to define an index on a column called ZipCode as below but I got the below error when doing 'Update-Database' by using code first migrations.

public string ZipCode { get; set; }

Column 'ZipCode' in table 'dbo.ServiceProviders' is of a type that is invalid for use as a key column in an index.

It turned out that it is a simple issue. The max length for an index column is 900 bytes. The fix is as simple as below.

public string ZipCode { get; set; }