ASP.NET Core:为所有模型生成剃刀页面 [英] ASP.NET Core : Generate Razor Pages for all models
问题描述
我已经使用数据库优先"方法和Razor Pages(无MVC)创建了一个ASP.NET Core 2.1项目.我所有的模型都是从数据库上下文生成的.
我使用这样的命令行为我的一个模型成功创建了CRUD Razor Pages:
dotnet aspnet-codegenerator razorpage -m Student -dc RazorDemoContext -udl -outDir Pages\Students
我大约有50多个模型.是否有一个命令行可以同时为所有模型生成CRUD Razor页面,而不是一个一个地生成?
谢谢
我建议您通过对数据库使用SELECT语句来生成脚本的整个列表:
select 'dotnet aspnet-codegenerator razorpage -m '+ name +' -dc RazorDemoContext -udl -outDir Pages\'+name+'s'
from sysobjects
where type = 'U'
I have created a ASP.NET Core 2.1 project With "Database first" approach and Razor Pages (no MVC). All my models are generated from the database context.
I successfully created CRUD Razor Pages for one of my models with a command line like this one :
dotnet aspnet-codegenerator razorpage -m Student -dc RazorDemoContext -udl -outDir Pages\Students
I have approximatively 50+ models. Is there a command line to generate CRUD Razor Pages for all models at the same time and not just one by one ?
Thank you
I suggest you produce the whole list of script by using a SELECT statement against your database :
select 'dotnet aspnet-codegenerator razorpage -m '+ name +' -dc RazorDemoContext -udl -outDir Pages\'+name+'s'
from sysobjects
where type = 'U'
这篇关于ASP.NET Core:为所有模型生成剃刀页面的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!