First I use the code to create my database. I will also use the full text for the search. However, I cannot create a full text index programmatically because the primary key index name given by EF is random. Is there any way to explicitly set this?
For example, I have a Items class, as shown below:
public class Item { public string ItemId { get; set; } public string ShortName { get; set; } public decimal Price { get; set; } public string Description { get; set; } public string ImageUri { get; set; } public string Tags { get; set; } public int CategoryId { get; set; } public string LastModifiedBy { get; set; } public virtual User LastModifiedBy { get; set; } public virtual ItemCategory Category { get; set; } public virtual ICollection<ItemMetaDataValue> MetaData{get;set;} public virtual ICollection<PriceHistoryLog> PriceHistory { get; set; } }
Now I want EF to create a full text directory for the Tags property, so I would call something like this using the DbContext.SqlCommand () method.
CREATE FULLTEXT CATALOG [DEFAULT]WITH ACCENT_SENSITIVITY = OFF AS DEFAULT AUTHORIZATION [dbo] CREATE FULLTEXT INDEX ON [dbo].[Items] KEY INDEX [PK__Items__727E838B07020F21] ON ([DEFAULT]) WITH (CHANGE_TRACKING AUTO) ALTER FULLTEXT INDEX ON [dbo].[Items] ADD ([Tags]) ALTER FULLTEXT INDEX ON [dbo].[Items] ENABLE
However, as you may have noticed, the primary key index name is not what I expect from it: PK_Items_727E838B07020F21. Does this key need to be explicitly specified?
Thanks.
source share