My Class
public class Dept_Master { [Key] public int Dept_Id { get; set; } [Index(IsUnique =true)] public string Dept_Name { get; set; } public bool status { get; set; } } Error on Following
Server Error in '/' Application.
Column 'Dept_Name' in table 'dbo.Dept_Master' is of a type that is invalid for use as a key columnin an index.
Description: An unhandled exception occurred during the
execution of the current web request. Please review the stack trace for more information about the error and where it originated in the code.
Exception Details: System.Data.SqlClient.SqlException: Column 'Dept_Name' in table 'dbo.Dept_Master' is of a type that is invalid for use as a key column in an index.

Dept_Nameis(n)varchar(max)which makes it non eligible for unique constraint