[英]How to add nonclustered indexes in Entity Framework db-first project?
I have a table in SQL Server which includes custom nonclustered indexes for some columns.我在 SQL 服务器中有一个表,其中包括某些列的自定义非聚集索引。 And I have also a project with below versions.
而且我还有一个低于版本的项目。
I added an entity data model to project based on my existing database (using a database-first approach).我添加了一个实体数据 model 到基于我现有数据库的项目中(使用数据库优先方法)。
Although a SELECT
query returns quickly in database, the same query gets a timeout error in the project.尽管
SELECT
查询在数据库中快速返回,但相同的查询在项目中出现超时错误。 And I thought that EF couldn't add column indexes to the project.而且我认为 EF 无法将列索引添加到项目中。 I searched index names in the project, but there isn't any code about indexes in the project.
我在项目中搜索了索引名称,但是项目中没有任何关于索引的代码。
So, how can I add indexes to my database-first model?那么,如何将索引添加到我的数据库优先 model?
So, how can I add indexes to my database-first model?
那么,如何将索引添加到我的数据库优先 model?
"database-first" means that you apply design changes to the database first , and then apply any changes to the EF model second. “数据库优先”意味着您首先将设计更改应用于数据库,然后再将任何更改应用于 EF model。
So you just create the indexes in SQL Server using Visual Studio or SSMS , and since EF model doesn't need to change when you add an index, you're done.因此,您只需使用Visual Studio或SSMS在 SQL 服务器中创建索引,并且由于 EF model 在添加索引时不需要更改,因此您完成了。
声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.