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

EF Core Power Tools stopped working in January #1661

Closed
LarryFireBreather opened this issue Jan 18, 2023 · 3 comments
Closed

EF Core Power Tools stopped working in January #1661

LarryFireBreather opened this issue Jan 18, 2023 · 3 comments
Labels
question Further information is requested

Comments

@LarryFireBreather
Copy link

I am reverse engineering a CEDS database. This worked last year every time I ran it. I am now running it to update my entities.

This year it started with an error which made me choose EF Core 7 on the dropdown on the first page of the dialog. I changed to that and got further but I got the error below. I tried running with both T4 and without. I tried deleting everything, the JSON config file, the entities, the context, etc. I tried removing the entire project and pulling it from GIT. I love your tool. I just need help. Please.

I am working on a DAL project for the solution.

ERROR:
System.InvalidOperationException: Reverse engineer error:
Microsoft.EntityFrameworkCore.Design.OperationException: Processing 'C:\GIT\msi-api\MSI_API.Infrastructure\CodeTemplates\EFCore\DbContext.t4' failed.
at void Microsoft.EntityFrameworkCore.Scaffolding.Internal.TextTemplatingModelGenerator.HandleErrors(TextTemplatingEngineHost host)
at ScaffoldedModel Microsoft.EntityFrameworkCore.Scaffolding.Internal.TextTemplatingModelGenerator.GenerateModel(IModel model, ModelCodeGenerationOptions options)
at ScaffoldedModel RevEng.Core.ReverseEngineerScaffolder.ScaffoldModel(string connectionString, DatabaseModelFactoryOptions databaseOptions, ModelReverseEngineerOptions modelOptions, ModelCodeGenerationOptions codeOptions, bool removeNullableBoolDefaults, bool dbContextOnly, bool entitiesOnly, bool useSchemaFolders) in C:/Code/Github/EFCorePowerTools/src/GUI/RevEng.Core/ReverseEngineerScaffolder.cs:line 375
at SavedModelFiles RevEng.Core.ReverseEngineerScaffolder.GenerateDbContext(ReverseEngineerCommandOptions options, List schemas, string outputContextDir, string modelNamespace, string contextNamespace, string projectPath, string outputPath) in C:/Code/Github/EFCorePowerTools/src/GUI/RevEng.Core/ReverseEngineerScaffolder.cs:line 103
at ReverseEngineerResult RevEng.Core.ReverseEngineerRunner.GenerateFiles(ReverseEngineerCommandOptions options) in C:/Code/Github/EFCorePowerTools/src/GUI/RevEng.Core/ReverseEngineerRunner.cs:line 88
at async Task EfReveng.Program.Main(string[] args) in C:/Code/Github/EFCorePowerTools/src/GUI/efreveng/Program.cs:line 69

at ReverseEngineerResult EFCorePowerTools.Handlers.ReverseEngineer.ResultDeserializer.BuildResult(string output)
at async Task EFCorePowerTools.Handlers.ReverseEngineer.EfRevEngLauncher.GetOutputAsync()
at async Task EFCorePowerTools.Handlers.ReverseEngineer.EfRevEngLauncher.LaunchExternalRunnerAsync(ReverseEngineerOptions options, CodeGenerationMode codeGenerationMode, Project project)
at async Task EFCorePowerTools.Handlers.ReverseEngineer.ReverseEngineerHandler.GenerateFilesAsync(Project project, ReverseEngineerOptions options, Tuple<bool, string> containsEfCoreReference, bool onlyGenerate)
at async Task EFCorePowerTools.Handlers.ReverseEngineer.ReverseEngineerHandler.ReverseEngineerCodeFirstAsync(Project project, string optionsPath, bool onlyGenerate, bool fromSqlProj)

When I run without T4

System.InvalidOperationException: Reverse engineer error:
System.NullReferenceException: Object reference not set to an instance of an object.
at string Microsoft.EntityFrameworkCore.Scaffolding.Internal.CSharpDbContextGenerator.TransformText()
at string Microsoft.EntityFrameworkCore.Scaffolding.Internal.CSharpModelGenerator.ProcessTemplate(ITextTransformation transformation)
at ScaffoldedModel Microsoft.EntityFrameworkCore.Scaffolding.Internal.CSharpModelGenerator.GenerateModel(IModel model, ModelCodeGenerationOptions options)
at ScaffoldedModel RevEng.Core.ReverseEngineerScaffolder.ScaffoldModel(string connectionString, DatabaseModelFactoryOptions databaseOptions, ModelReverseEngineerOptions modelOptions, ModelCodeGenerationOptions codeOptions, bool removeNullableBoolDefaults, bool dbContextOnly, bool entitiesOnly, bool useSchemaFolders) in C:/Code/Github/EFCorePowerTools/src/GUI/RevEng.Core/ReverseEngineerScaffolder.cs:line 375
at SavedModelFiles RevEng.Core.ReverseEngineerScaffolder.GenerateDbContext(ReverseEngineerCommandOptions options, List schemas, string outputContextDir, string modelNamespace, string contextNamespace, string projectPath, string outputPath) in C:/Code/Github/EFCorePowerTools/src/GUI/RevEng.Core/ReverseEngineerScaffolder.cs:line 103
at ReverseEngineerResult RevEng.Core.ReverseEngineerRunner.GenerateFiles(ReverseEngineerCommandOptions options) in C:/Code/Github/EFCorePowerTools/src/GUI/RevEng.Core/ReverseEngineerRunner.cs:line 88
at async Task EfReveng.Program.Main(string[] args) in C:/Code/Github/EFCorePowerTools/src/GUI/efreveng/Program.cs:line 69

at ReverseEngineerResult EFCorePowerTools.Handlers.ReverseEngineer.ResultDeserializer.BuildResult(string output)
at async Task EFCorePowerTools.Handlers.ReverseEngineer.EfRevEngLauncher.GetOutputAsync()
at async Task EFCorePowerTools.Handlers.ReverseEngineer.EfRevEngLauncher.LaunchExternalRunnerAsync(ReverseEngineerOptions options, CodeGenerationMode codeGenerationMode, Project project)
at async Task EFCorePowerTools.Handlers.ReverseEngineer.ReverseEngineerHandler.GenerateFilesAsync(Project project, ReverseEngineerOptions options, Tuple<bool, string> containsEfCoreReference, bool onlyGenerate)
at async Task EFCorePowerTools.Handlers.ReverseEngineer.ReverseEngineerHandler.ReverseEngineerCodeFirstAsync(Project project, string optionsPath, bool onlyGenerate, bool fromSqlProj)

Provide steps to reproduce

{
"CodeGenerationMode": 3,
"ContextClassName": "MSIContext",
"ContextNamespace": null,
"DefaultDacpacSchema": null,
"FilterSchemas": false,
"IncludeConnectionString": false,
"ModelNamespace": null,
"OutputContextPath": "Context",
"OutputPath": "Entities",
"PreserveCasingWithRegex": true,
"ProjectRootNamespace": "MSI_API.Infrastructure",
"Schemas": null,
"SelectedHandlebarsLanguage": 2,
"SelectedToBeGenerated": 0,
"Tables": [
{
"Name": "[clean].[Location]",
"ObjectType": 0
},
{
"Name": "[clean].[Organization]",
"ObjectType": 0
},

  {
     "Name": "[dbo].[ELChildDemographic]",
     "ObjectType": 0
  }.

/* etc etc */

  {
     "Name": "[Staging].[SiteLCGMS]",
     "ObjectType": 0
  }

],
"UiHint": "ES00vDADOSQL109.MSI",
"UncountableWords": null,
"UseBoolPropertiesWithoutDefaultSql": false,
"UseDatabaseNames": true,
"UseDateOnlyTimeOnly": false,
"UseDbContextSplitting": false,
"UseFluentApiOnly": false,
"UseHandleBars": false,
"UseHierarchyId": false,
"UseInflector": true,
"UseLegacyPluralizer": false,
"UseManyToManyEntity": false,
"UseNoDefaultConstructor": false,
"UseNoObjectFilter": false,
"UseNodaTime": false,
"UseNullableReferences": false,
"UseSchemaFolders": false,
"UseSpatial": false,
"UseT4": true
}
Please include a complete description or project that I can redo/run to reproduce the issue.

Provide technical details

  • EF Core version in use: 7

  • Is Handlebars used: no/yes - false

  • Is T4 used: - true

  • Is .dacpac used: no/yes

  • EF Core Power Tools version: 2.5.1267

  • Database engine: SQL Server

  • Visual Studio version: Visual Studio 2022

@ErikEJ
Copy link
Owner

ErikEJ commented Jan 18, 2023

it is a good idea to search for similar closed issues...

Were you using EF Core 5 before?

See dotnet/efcore#29516 for this issue and workarounds - a fix will be available in mid Feb 2023

@LarryFireBreather
Copy link
Author

LarryFireBreather commented Jan 19, 2023 via email

@ErikEJ ErikEJ closed this as not planned Won't fix, can't repro, duplicate, stale Jan 19, 2023
@ErikEJ
Copy link
Owner

ErikEJ commented Jan 19, 2023

Thanks for the kind words. I would be very grateful for a rating or review on Visual Studio Marketplace

@ErikEJ ErikEJ added the question Further information is requested label Jan 19, 2023
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
question Further information is requested
Projects
None yet
Development

No branches or pull requests

2 participants