ErikEJ / EFCorePowerTools

Entity Framework Core Power Tools - reverse engineering, migrations and model visualization in Visual Studio & CLI
MIT License
2.13k stars 294 forks source link

EF Core Power Tools stopped working in January #1661

Closed LarryFireBreather closed 1 year ago

LarryFireBreather commented 1 year ago

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

ErikEJ commented 1 year ago

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

Were you using EF Core 5 before?

See https://github.com/dotnet/efcore/issues/29516 for this issue and workarounds - a fix will be available in mid Feb 2023

LarryFireBreather commented 1 year ago

Erik, THANK YOU! That was it! 2 Things I didn’t realize, there was an indicator on the table icon (old eyes missed that detail) and there were “closed” issues.

LOVE your product! Thank you so much for your quick response!

Thank you, —Larry—

Lawrence Farrell [signature_1593138464] 1149 Bloomfield Ave. Suite G, Clifton, NJ 07012 C: 551-804-8818 @.**@.> | sprucetech.comhttp://www.sprucetech.com/

From: Erik Ejlskov Jensen @.> Sent: Wednesday, January 18, 2023 5:18 PM To: ErikEJ/EFCorePowerTools @.> Cc: Lawrence Farrell @.>; Author @.> Subject: Re: [ErikEJ/EFCorePowerTools] EF Core Power Tools stopped working in January (Issue #1661)

EXTERNAL SENDER

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

Were you using EF Core 5 before?

See dotnet/efcore#29516https://github.com/dotnet/efcore/issues/29516 for this issue and workarounds - a fix will be available in mid Feb 2023

— Reply to this email directly, view it on GitHubhttps://github.com/ErikEJ/EFCorePowerTools/issues/1661#issuecomment-1396167361, or unsubscribehttps://github.com/notifications/unsubscribe-auth/A2EIMZZMRRJ374GQUP5WURTWTBTZVANCNFSM6AAAAAAT7TSHZY. You are receiving this because you authored the thread.Message ID: @.***>

ErikEJ commented 1 year ago

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