{"record":{"id":"0568b8c2c78ee0de","repo":"dotnet/efcore","slug":"no-files-were-generated-in-directory-outputdirec-0568b8","errorCode":null,"errorMessage":"No files were generated in directory '{outputDirectoryName}'. The following file(s) already exist(s) and must be made writeable to continue: {readOnlyFiles}.","messagePattern":"No files were generated in directory '(.+?)'\\. The following file\\(s\\) already exist\\(s\\) and must be made writeable to continue: (.+?)\\.","errorType":"exception","errorClass":"OperationException","httpStatus":null,"severity":"error","filePath":"src/EFCore.Design/Scaffolding/Internal/ReverseEngineerScaffolder.cs","lineNumber":187,"sourceCode":"                if (File.GetAttributes(fullPath).HasFlag(FileAttributes.ReadOnly))\n                {\n                    readOnlyFiles.Add(path);\n                }\n            }\n        }\n\n        if (!overwriteFiles\n            && existingFiles.Count != 0)\n        {\n            throw new OperationException(\n                DesignStrings.ExistingFiles(\n                    outputDir,\n                    string.Join(CultureInfo.CurrentCulture.TextInfo.ListSeparator, existingFiles)));\n        }\n\n        if (readOnlyFiles.Count != 0)\n        {\n            throw new OperationException(\n                DesignStrings.ReadOnlyFiles(\n                    outputDir,\n                    string.Join(CultureInfo.CurrentCulture.TextInfo.ListSeparator, readOnlyFiles)));\n        }\n    }\n}\n","sourceCodeStart":169,"sourceCodeEnd":194,"githubUrl":"https://github.com/dotnet/efcore/blob/3a2006ef569de08368d59db5e1468aa8f407e4f8/src/EFCore.Design/Scaffolding/Internal/ReverseEngineerScaffolder.cs#L169-L194","documentation":"Thrown during scaffolding when target files exist but are marked read-only (e.g. FileAttributes.ReadOnly), so EF Core cannot overwrite them even though overwrite was requested or they are the only blockers. The message lists the offending read-only files and instructs making them writeable.","triggerScenarios":"Scaffolding with overwriteFiles=true (or no non-readonly collisions) where at least one output path resolves to a file with the ReadOnly attribute set. Detected via File.GetAttributes(fullPath).HasFlag(FileAttributes.ReadOnly).","commonSituations":"Files checked out as read-only by an older TFS/SCM, files copied from a read-only share or CD image, files with the readonly bit set after a failed tool run, or files on a network mount with write protection.","solutions":["Clear the ReadOnly attribute on the listed files: `attrib -R <files>` on Windows or `chmod u+w <files>` on Unix.","Close any editor/IDE or SCM that is locking the files read-only, then re-run scaffold.","Delete the listed files and let scaffolding recreate them.","Move the output to a directory you fully own and re-run."],"exampleFix":"# before: files are read-only\nattrib +r MyContext.cs\n# after: clear the bit, then scaffold\nattrib -r MyContext.cs Models\\*.cs\ndotnet ef dbcontext scaffold \"...\" Microsoft.EntityFrameworkCore.SqlServer --force","handlingStrategy":"validation","validationCode":"foreach (var f in Directory.GetFiles(outputDir, \"*.cs\", SearchOption.AllDirectories))\n{\n    if (File.GetAttributes(f).HasFlag(FileAttributes.ReadOnly))\n        File.SetAttributes(f, File.GetAttributes(f) & ~FileAttributes.ReadOnly);\n}","typeGuard":null,"tryCatchPattern":"try { scaffolder.ScaffoldModel(...); }\ncatch (OperationException ex) when (ex.Message.Contains(\"writeable\"))\n{\n    foreach (var f in ListedFrom(ex)) File.SetAttributes(f, FileAttributes.Normal);\n    scaffolder.ScaffoldModel(...);\n}","preventionTips":["Run scaffold from a working copy you own, not a read-only share.","Clear the ReadOnly bit in your pre-scaffold script.","Avoid checking out files as read-only from SCM before regenerating."],"tags":["scaffolding","reverse-engineering","filesystem","design-time"],"backgroundTag":null,"analyzedSha":"3a2006ef569de08368d59db5e1468aa8f407e4f8","analyzedAt":"2026-08-11T23:42:04.146Z","contentChangedAt":null,"schemaVersion":2},"datasetVersion":"2026-09-14T00:17:10.932Z"}