如何解决尝试找出模型和DbContext的EntityFramework元数据:'Employee'
我正在尝试从命令中生成驱动程序。
dotnet aspnet-codegenerator controller -name EmployeeController -m Employee -dc EmsContext --relativeFolderPath Controllers --useDefaultLayout --referenceScriptLibraries
Attempting to figure out the EntityFramework metadata for the model and DbContext: 'Employee'
A file matching the name MvcControllerWithContext.cshtml was not found within any of the folders:
at Microsoft.VisualStudio.Web.CodeGeneration.ActionInvoker.<BuildCommandLine>b__6_0()
at Microsoft.Extensions.CommandLineUtils.CommandLineApplication.Execute(String[] args)
at Microsoft.VisualStudio.Web.CodeGeneration.ActionInvoker.Execute(String[] args)
at Microsoft.VisualStudio.Web.CodeGeneration.CodeGenCommand.Execute(String[] args)
这是文档中的最后一步,我从此框架开始,但无法摆脱这种状况。我正在使用Ubuntu以及整个终端。如果有人可以给我一些解决方法的指示,我将不胜感激。
解决方法
作为@ ericc-eacs答案,您需要复制模板,如果您只是按照入门教程(.net核心)进行操作,请确保将文件夹删除到身份模板中,因为在构建时,它会给您一些错误。您只需要模板即可创建视图和控制器。
,您使用的是哪个版本的dotnetcore SDK?
dotnet --version
您可能需要安装其他版本的aspnet-codegenerator。 一些有用的命令:
dotnet tool uninstall --global dotnet-aspnet-codegenerator
dotnet tool install --global dotnet-aspnet-codegenerator --version 3.1.0
dotnet tool update -g dotnet-aspnet-codegenerator
,
我有适用于UBUNTU的解决方案,适用于网络核心3.0,3.1和5.0。 2020年11月27日
ControllerGenerator包含文件MvcControllerWithContext.cshtml
您只需将Templates文件夹复制 Template / ControllerGenerator和Templete / ViewGenerator到自己的项目。
在此示例中查看版本为5.0.0 enter image description here 这是丢失文件的路径:/home/$USER/.nuget/packages/microsoft.visualstudio.web.codegenerators.mvc/5.0.0/Templates
,我可以确认这个问题至少自 11 月以来就存在,并且尚未找到解决方案。使用 Ubuntu 18.04.5 LTS、Rider EAP 2020.3。 C# 9,dotnet-aspnet-codegenerator 版本“5.0.1”,dotnet 5.0.102。
运行该实用程序为 Razor Pages Web 应用程序构建 crud 页面时:
dotnet aspnet-codegenerator razorpage -m GpsSession -dc ApplicationDbContext -udl -outDir Pages/GpsSessions --referenceScriptLibraries
给出以下输出:
Building project ...
Finding the generator 'razorpage'...
Running the generator 'razorpage'...
Attempting to figure out the EntityFramework metadata for the model and DbContext: 'GpsSession'
A file matching the name Create.cshtml was not found within any of the folders:
at Microsoft.VisualStudio.Web.CodeGeneration.ActionInvoker.<BuildCommandLine>b__6_0()
at Microsoft.Extensions.CommandLineUtils.CommandLineApplication.Execute(String[] args)
at Microsoft.VisualStudio.Web.CodeGeneration.ActionInvoker.Execute(String[] args)
at Microsoft.VisualStudio.Web.CodeGeneration.CodeGenCommand.Execute(String[] args)
当我在 Win10 中的同一个存储库上运行相同的命令时,一切正常,生成的 crud 页面没有任何错误。
版权声明:本文内容由互联网用户自发贡献,该文观点与技术仅代表作者本人。本站仅提供信息存储空间服务,不拥有所有权,不承担相关法律责任。如发现本站有涉嫌侵权/违法违规的内容, 请发送邮件至 dio@foxmail.com 举报,一经查实,本站将立刻删除。