Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

ISSUE: Exclude indexes is being overwritten by reverse engineering in the efpt.config.json file #2640

Closed
chassq opened this issue Nov 20, 2024 · 15 comments · Fixed by #2649
Closed
Labels
bug Something isn't working reveng

Comments

@chassq
Copy link

chassq commented Nov 20, 2024

We are trying to use the deature noted in #2520 and in the docs as

"You can also exclude indexes (SQL Server only), for example to work around this EF Core bug - add a list of ExcludedIndexes strings to your table object in efpt.config.json. CLI: excludedIndexes"

Provide steps to reproduce a bug

Add the ExcludedIndexes section to a table definition in the efpt.config.json. For example:

{
  "name": "[dbo].[Folder]",
  "exclude": false,
  "ExcludedIndexes": [
    "UX_Folder_CompanyId_TopLevelFolder"
  ]
}
Our Config w/o the entry:
{
   "CodeGenerationMode": 4,
   "ContextClassName": "MyAppDbContext",
   "ContextNamespace": "",
   "FilterSchemas": false,
   "IncludeConnectionString": false,
   "ModelNamespace": "",
   "OutputContextPath": "Context",
   "OutputPath": "Model",
   "PreserveCasingWithRegex": true,
   "ProjectRootNamespace": "MyApp.Database.Sql",
   "Schemas": null,
   "SelectedHandlebarsLanguage": 2,
   "SelectedToBeGenerated": 0,
   "T4TemplatePath": null,
   "Tables": [
      {
         "Name": "[dbo].[Folder",
         "ObjectType": 0
      }
   ],
   "UiHint": null,
   "UncountableWords": null,
   "UseAsyncStoredProcedureCalls": true,
   "UseBoolPropertiesWithoutDefaultSql": false,
   "UseDatabaseNames": false,
   "UseDateOnlyTimeOnly": true,
   "UseDbContextSplitting": true,
   "UseDecimalDataAnnotationForSprocResult": true,
   "UseFluentApiOnly": true,
   "UseHandleBars": false,
   "UseHierarchyId": false,
   "UseInflector": false,
   "UseLegacyPluralizer": false,
   "UseManyToManyEntity": false,
   "UseNoDefaultConstructor": false,
   "UseNoNavigations": false,
   "UseNoObjectFilter": false,
   "UseNodaTime": false,
   "UseNullableReferences": false,
   "UsePrefixNavigationNaming": false,
   "UseSchemaFolders": true,
   "UseSchemaNamespaces": true,
   "UseSpatial": false,
   "UseT4": false,
   "UseT4Split": false
}

We run the reverse engineering, and the entry disappears from the efpt.config.json

Provide technical details

  • EF Core Power Tools version: 2.6.632

  • Exact Visual Studio version: Visual Studio 2022 Version 17.12.0 Preview 5.0

  • Database engine: Azure SQL

  • EF Core version in use: EF Core 8

  • Is Handlebars templates used: no

  • Is T4 templates used: no

  • Is a SQL Server .dacpac used: yes

@ErikEJ ErikEJ added bug Something isn't working reveng labels Nov 20, 2024
@ErikEJ
Copy link
Owner

ErikEJ commented Nov 24, 2024

@chassq I am inestigateing this bug. Note that "exclude" has no effect in efpt.config.json.

@ErikEJ
Copy link
Owner

ErikEJ commented Nov 24, 2024

I implemented a fix for this in the latest daily build, would be grateful if you could try it out.

@chassq
Copy link
Author

chassq commented Nov 24, 2024

I just pulled down version 2.6.653. Shut down VS 2022. Installed the new vsix file. I hand entered into the efpt.config.json file the following entry on the applicable table:

      "ExcludedIndexes": [
        "UIX_MyTable_Endpoint_Id_Type"
      ]

I then ran the reverse engineer and observed the entry was removed from the efpt.config.json file and the reverse engineer had not excluded the index. Did I perhaps do something wrong?

@ErikEJ
Copy link
Owner

ErikEJ commented Nov 24, 2024

You did nothing wrong, but you need build .655 or later.

@chassq
Copy link
Author

chassq commented Nov 24, 2024

Hey Erik,

So I did the same as above with version .655. The entries are now staying in the efpt.config.json when the reverse engineer runs but the indexes are not being ignored. They are still writing to the configuration files and the models are seeing the filtered unique indexes as a single object not a collection. I guess if the index was being ignored the configuration would not show it and the FK ref would be a collection in this case.

@ErikEJ ErikEJ reopened this Nov 24, 2024
@ErikEJ
Copy link
Owner

ErikEJ commented Nov 24, 2024

Thanks for the feedback, I will have another look.

@ErikEJ
Copy link
Owner

ErikEJ commented Nov 24, 2024

@chassq Ah - are you using a .dacpac?

@chassq
Copy link
Author

chassq commented Nov 24, 2024

yes we are using a dacpac. For example, we are pointing the reverse engineer directly at the SQL Project. It says (.dacpac) in the drop down selection

@ErikEJ
Copy link
Owner

ErikEJ commented Nov 24, 2024

Sorry, I missed that. The feature was never added to .dacpac reverse engineering

@chassq
Copy link
Author

chassq commented Nov 24, 2024

Ah I see. Is it possible to do so?

@ErikEJ
Copy link
Owner

ErikEJ commented Nov 24, 2024

Oh yes, working on it!

ErikEJ added a commit that referenced this issue Nov 24, 2024
@ErikEJ ErikEJ closed this as completed in c375ad3 Nov 24, 2024
@ErikEJ
Copy link
Owner

ErikEJ commented Nov 24, 2024

I did another attempt, pls try build. 656 or later

@chassq
Copy link
Author

chassq commented Nov 24, 2024

Trying now

@chassq
Copy link
Author

chassq commented Nov 24, 2024

Hey Erik, this looks good. Seems like it is working as expected. Thanks for this!!!

@ErikEJ
Copy link
Owner

ErikEJ commented Nov 24, 2024

Wonderful and thanks for the heads up

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
bug Something isn't working reveng
Projects
None yet
Development

Successfully merging a pull request may close this issue.

2 participants