Closed aeslinger0 closed 4 years ago
What is the version of your EF Core packages?
I'm using .Net Core 3.1 and these are the NuGet Packages I'm using:
Let me reproduce then.
That fixed it. Thanks for the speedy response @tonysneed!
The new NuGet package v3.8.1 has the fix.
I have the same issue while running
dotnet ef dbcontext scaffold "connectionstring" Microsoft.EntityFrameworkCore.SqlServer -o Models --schema dbo --context MyDataContext -f
for the first time
System.IO.DirectoryNotFoundException: Could not find a part of the path 'C:\source\api\api.dbup\bin\Debug\net5.0\CodeTemplates\CSharpDbContext\Partials\DbImports.hbs'.
at System.IO.FileStream.ValidateFileHandle(SafeFileHandle fileHandle)
at System.IO.FileStream.CreateFileOpenHandle(FileMode mode, FileShare share, FileOptions options)
at System.IO.FileStream..ctor(String path, FileMode mode, FileAccess access, FileShare share, Int32 bufferSize, FileOptions options)
at System.IO.StreamReader.ValidateArgsAndOpenPath(String path, Encoding encoding, Int32 bufferSize)
at System.IO.StreamReader..ctor(String path, Encoding encoding, Boolean detectEncodingFromByteOrderMarks)
at System.IO.File.InternalReadAllText(String path, Encoding encoding)
at System.IO.File.ReadAllText(String path)
at EntityFrameworkCore.Scaffolding.Handlebars.Internal.FileSystemFileService.RetrieveFileContents(String directoryName, String fileName)
at EntityFrameworkCore.Scaffolding.Handlebars.FileSystemTemplateFileService.RetrieveTemplateFileContents(String relativeDirectory, String fileName, String altRelativeDirectory)
at EntityFrameworkCore.Scaffolding.Handlebars.HbsDbContextTemplateService.GetPartialTemplates(LanguageOptions language)
at EntityFrameworkCore.Scaffolding.Handlebars.HbsTemplateService.RegisterPartialTemplates()
at EntityFrameworkCore.Scaffolding.Handlebars.HbsCSharpModelGenerator.GenerateModel(IModel model, ModelCodeGenerationOptions options)
at Microsoft.EntityFrameworkCore.Scaffolding.Internal.ReverseEngineerScaffolder.ScaffoldModel(String connectionString, DatabaseModelFactoryOptions databaseOptions, ModelReverseEngineerOptions modelOptions, ModelCodeGenerationOptions codeOptions)
at Microsoft.EntityFrameworkCore.Design.Internal.DatabaseOperations.ScaffoldContext(String provider, String connectionString, String outputDir, String outputContextDir, String dbContextClassName, IEnumerable`1 schemas, IEnumerable`1 tables, String modelNamespace, String contextNamespace, Boolean useDataAnnotations, Boolean overwriteFiles, Boolean useDatabaseNames, Boolean suppressOnConfiguring, Boolean noPluralize)
at Microsoft.EntityFrameworkCore.Design.OperationExecutor.ScaffoldContextImpl(String provider, String connectionString, String outputDir, String outputDbContextDir, String dbContextClassName, IEnumerable`1 schemaFilters, IEnumerable`1 tableFilters, String modelNamespace, String contextNamespace, Boolean useDataAnnotations, Boolean overwriteFiles, Boolean useDatabaseNames, Boolean suppressOnConfiguring, Boolean noPluarlize)
at Microsoft.EntityFrameworkCore.Design.OperationExecutor.ScaffoldContext.<>c__DisplayClass0_0.<.ctor>b__0()
at Microsoft.EntityFrameworkCore.Design.OperationExecutor.OperationBase.<>c__DisplayClass3_0`1.<Execute>b__0()
at Microsoft.EntityFrameworkCore.Design.OperationExecutor.OperationBase.Execute(Action action)
@egorpavlikhin Created a new issue for you #155.
Describe the bug The CodeTemplates folder is not getting created on first run. The documentation says "You will also see a CodeTemplates folder appear containing Handlebars templates for customizing generation of context and entity type classes." This is not happening
Expected behavior Templates appear when the
dotnet ef dbcontext scaffold ...
command is ran.To Reproduce Just follow the documentation to reproduce the behavior.
Additional context I get this error instead: