I\'m running EF 4.2 CF and want to create indexes on certain columns in my POCO objects.
As an example lets say we have this employee class:
public c
expanding on Petoj
i modified the CreateIndexQueryTemplate to
private const string CreateIndexQueryTemplate = "IF NOT EXISTS (SELECT name FROM sysindexes WHERE name = '{indexName}') CREATE {unique} INDEX {indexName} ON {tableName} ({columnName});";
and removed the following from OnModelCreating
Database.SetInitializer(new IndexInitializer());
and added the following to Configuration Seeding method
new IndexInitializer().InitializeDatabase(context);
this way the index attributes are run every time you do a update-database.