Automatically detect all models to scaffold

五迷三道 提交于 2019-12-06 12:00:23

Abbas,

I've been using the MVCScaffolding template (with EF code-first) and the way that this works is that you create your domain model(s) and then scaffold ALL objects that have a domain model. This template will actually skip the scaffold for any pre-existing controllers/views that have been scaffolded. However, there is also an override command (-FORCE) which will then overwrite any/all pre-exisiting scaffolded code if you so wish.

here's the quick link:

http://blog.stevensanderson.com/2011/01/13/scaffold-your-aspnet-mvc-3-project-with-the-mvcscaffolding-package/

@jim: You didn't provide a direct answer (which I did not demand) but you sure got me on the way for which I thank you very much. I went looking into the templates and by studying these a bit, I found a solution to get the models from the Model folder. It might not be the perfect solution, but this works perfectly:

$modelFolder = Get-ProjectFolder "Models\"
foreach($file in $modelFolder)
{
    $model = $file.Name.Replace(".cs", "")
    Scaffold CustomController $model -Force
}
易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!