Entity Framework 6.1.1 Naming Convention for Indexes

I understand how to add agreements to the first project (with migrations). I successfully completed the table names and even changed the GUID fields to non-clustered.

But I did not find how to change the default index name that EF provides when the name is not specified.

[Index(IsUnique = true)]
public string Code { get; set; }

[Index]
public string Description { get; set; }

I have these two requirements. Superscript should be called UX_[schema]_[table]_CodesecondIX_[schema]_[table]_Description

I also need to maintain multiple column indexes, where IsUnique will still be UX, but the column section is a combination of the camel list of all columns (for example UX_[schema]_[table]_CodeDescription, if two columns are higher, where at the same index.

I assume that I will need to add this after IndexAttributeConvention so that all current functions work and create IndexAnnotations. But I can’t find where the indexes get their original name if they are left empty in the attribute (or in the Free construct).

Thanks in advance.

+4
source share
1 answer

Have you tried this annotation: [Index ("IndexName")] or for your example:

[Index("IndexName", IsUnique = true)]
public string Code { get; set; }
-1
source

All Articles