Entity Framework Indexing ALL foreign key columns

后端 未结 2 557
礼貌的吻别
礼貌的吻别 2020-12-20 16:53

This may be too much of an opinion-based question but here goes:

I\'ve found an interesting quirk with Entity Framework and database migrations. It seems that whene

2条回答
  •  不思量自难忘°
    2020-12-20 17:28

    Short answer. No.

    To expand slightly, at the database create time, entity framework does not know how many records each table or entity will have, nor does it know how the entities will be queried.

    *In my opinion * the creation of a foreign key is more likely to be right than wrong, I had massive performance issues using a different ORM which took longer to diagnose because I thought I had read in the documentation that it behaved the same way.

    You can check the Sql statement that EF produces and run it manually if you want to double check.

    You know your data better than EF does, and it should work just fine if you drop the index manually.

    IIRC you can create 1 way navigation properties if you use the right naming convention, although this was some time ago, and I never checked whether the index was created.

提交回复
热议问题