Whereas you are using Entity Framework 6`, you would have two options.
"Fluent Api", which would be the example of your question. That is, yes you can and at my view should create a Unique Key
, as in your example:
HasIndex(x=>x.Atributo).IsUnique()
The second way would be Data Annotation Attribute, is an option but I don’t like it because I work with "POCO" classes, and these attributes polououem the code. But it would look like this.
Supposing your property is called X
[Index( "INDEX_x", IsUnique=true )]
public string x {get;set;}
Asking the answer to inform that the solution also works for EF Core.
Which EF version you are using?
– Rodrigo K.B