File tree Expand file tree Collapse file tree 1 file changed +13
-3
lines changed
Expand file tree Collapse file tree 1 file changed +13
-3
lines changed Original file line number Diff line number Diff line change @@ -34,9 +34,19 @@ protected SqliteInitializerBase(DbModelBuilder modelBuilder)
3434 // See https://github.com/msallin/SQLiteCodeFirst/issues/7 for details.
3535 modelBuilder . Conventions . Remove < TimestampAttributeConvention > ( ) ;
3636
37- // Place the own ForeinKeyIndexConvention right after the original.
38- // The own convention will rename the automatically created indicies by using the correct scheme.
39- modelBuilder . Conventions . AddAfter < ForeignKeyIndexConvention > ( new SqliteForeignKeyIndexConvention ( ) ) ;
37+ // By default there is a 'ForeignKeyIndexConvention' but it can be removed.
38+ // And there is no "Contains" and no way to enumerate the ConventionsCollection.
39+ // So a try/catch will do the job.
40+ try
41+ {
42+ // Place the own ForeinKeyIndexConvention right after the original.
43+ // The own convention will rename the automatically created indicies by using the correct scheme.
44+ modelBuilder . Conventions . AddAfter < ForeignKeyIndexConvention > ( new SqliteForeignKeyIndexConvention ( ) ) ;
45+ }
46+ catch ( InvalidOperationException exception )
47+ {
48+ // Ignore it.
49+ }
4050 }
4151
4252 /// <summary>
You can’t perform that action at this time.
0 commit comments