question-mark
Stuck on an issue?

Lightrun Answers was designed to reduce the constant googling that comes with debugging 3rd party libraries. It collects links to all the places you might be looking at while hunting down a tough bug.

And, if you’re still stuck at the end, we’re happy to hop on a call to see how we can help out.

Could not find file '[project root]\CodeTemplates\CSharpDbContext\Partials\DbConstructor.hbs

See original GitHub issue

When trying to reverse engineer using Handlebars templates, the output shows System.IO.FileNotFoundException: Could not find file '[project root]\CodeTemplates\CSharpDbContext\Partials\DbConstructor.hbs'.

Steps to reproduce

Using Reverse Engineer tool:

  • What to generate: EntityTypes & DbContext
  • Check “Customize code using Handlebars templates (preview)”

Further technical details

EF Core Power Tools version: 2.2.4

Database engine: SQL Server

Visual Studio version: 15.9.5

Stack trace:

System.IO.FileNotFoundException: Could not find file '[project root]\CodeTemplates\CSharpDbContext\Partials\DbConstructor.hbs'.
File name: [project root]\CodeTemplates\CSharpDbContext\Partials\DbConstructor.hbs'
   at System.IO.__Error.WinIOError(Int32 errorCode, String maybeFullPath)
   at System.IO.FileStream.Init(String path, FileMode mode, FileAccess access, Int32 rights, Boolean useRights, FileShare share, Int32 bufferSize, FileOptions options, SECURITY_ATTRIBUTES secAttrs, String msgPath, Boolean bFromProxy, Boolean useLongPath, Boolean checkHost)
   at System.IO.FileStream..ctor(String path, FileMode mode, FileAccess access, FileShare share, Int32 bufferSize, FileOptions options, String msgPath, Boolean bFromProxy, Boolean useLongPath, Boolean checkHost)
   at System.IO.StreamReader..ctor(String path, Encoding encoding, Boolean detectEncodingFromByteOrderMarks, Int32 bufferSize, Boolean checkHost)
   at System.IO.File.InternalReadAllText(String path, Encoding encoding, Boolean checkHost)
   at System.IO.File.ReadAllText(String path)
   at EntityFrameworkCore.Scaffolding.Handlebars.Internal.FileSystemFileService.RetrieveFileContents(String directoryName, String fileName)
   at ReverseEngineer20.ReverseEngineer.CustomTemplateFileService.RetrieveTemplateFileContents(String relativeDirectory, String fileName, String altRelativeDirectory)
   at EntityFrameworkCore.Scaffolding.Handlebars.HbsDbContextTemplateService.GetPartialTemplates()
   at EntityFrameworkCore.Scaffolding.Handlebars.HbsTemplateService.RegisterPartialTemplates()
   at EntityFrameworkCore.Scaffolding.Handlebars.HbsCSharpModelGenerator.GenerateModel(IModel model, String namespace, String contextDir, String contextName, String connectionString, ModelCodeGenerationOptions options)
   at Microsoft.EntityFrameworkCore.Scaffolding.Internal.ReverseEngineerScaffolder.ScaffoldModel(String connectionString, IEnumerable`1 tables, IEnumerable`1 schemas, String namespace, String language, String contextDir, String contextName, ModelReverseEngineerOptions modelOptions, ModelCodeGenerationOptions codeOptions)
   at ReverseEngineer20.EfCoreReverseEngineer.GenerateFiles(ReverseEngineerOptions reverseEngineerOptions)
   at EFCorePowerTools.Handlers.ReverseEngineerHandler.<ReverseEngineerCodeFirst>d__2.MoveNext() in C:\projects\efcorepowertools\src\GUI\EFCorePowerTools\Handlers\ReverseEngineerHandler.cs:line 193

Issue Analytics

  • State:closed
  • Created 5 years ago
  • Comments:9 (6 by maintainers)

github_iconTop GitHub Comments

1reaction
ErikEJcommented, Jan 26, 2019

(I have confirmed the workaround fixes the issue)

1reaction
ErikEJcommented, Jan 24, 2019

Did you try a folder rename?

Read more comments on GitHub >

github_iconTop Results From Across the Web

TFS checkin error - could not find file
My fix: 1. Exclude the old project and (any related files with this warning) from check-in. 2. Check in your changes. 3. With...
Read more >
Frequently Asked Questions - Research Computing Services
How can I request a change to an existing project space on the HBSGrid, including requesting more storage space? Please fill out this...
Read more >
Copying Files to/from the HBSGrid
Copying files between computers is made easy via terminal and GUI. But before you start the copying process please pause a moment and...
Read more >
Accessing Spaces & Storage - Research Computing Services
You can connect to your research storage project spaces and home folders by using the familiar Finder "Connect to Server…" option: Connect to...
Read more >
Failed - Could not find file"-message in an AutoCAD Plant ...
When closing project setup and checking-in the project, an error pops up: Plant Project Collaboration Error encountered Failed Could not ...
Read more >

github_iconTop Related Medium Post

No results found

github_iconTop Related StackOverflow Question

No results found

github_iconTroubleshoot Live Code

Lightrun enables developers to add logs, metrics and snapshots to live code - no restarts or redeploys required.
Start Free

github_iconTop Related Reddit Thread

No results found

github_iconTop Related Hackernoon Post

No results found

github_iconTop Related Tweet

No results found

github_iconTop Related Dev.to Post

No results found

github_iconTop Related Hashnode Post

No results found