Asp.Net核心2.0 Mvc应用程序错误 [英] Asp.Net core 2.0 Mvc app error

查看:72
本文介绍了Asp.Net核心2.0 Mvc应用程序错误的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

拥有我转换为2.0的Asp.net核心1.1 Mvc应用程序,其中包含自定义模板/文件夹。 当我尝试添加控制器w EF操作时,我收到以下错误:
$






我假设有核心2.0的更新模板,但不知道在哪里找到他们??

解决方案

你好Alex,


欢迎来到MSDN论坛。


请参阅错误消息,请检查以下类似问题:

迁移1.1到2.0:脚手架多个问题
并尝试N提供的以下解决方案icolasREY:


我检查了差异,这里是强制修改:


< span style ="font-family:'Calibri',sans-serif; font-size:11pt"> Templates \ ControllerGenerator \ MVcControllerWithContext.cshtml


添加:


@ using System.Collections.Generic;

@using System.Linq;


另外:


使用System.Collections.Generic;

使用System.Linq;


所以'标题'看起来像:


@ inherits Microsoft.VisualStudio.Web.CodeGeneration.Templating.RazorTemplateBase

@using System.Collections.Generic;

@using System.Linq;

使用System;

使用System.Collections.Generic;

使用System .Linq;

使用System.Threading.Tasks;

使用Microsoft.AspNetCore.Mvc;

使用Microsoft.AspNetCore.Mvc.Rendering;

使用Microsoft.EntityFrameworkCore;


Templates\ViewGenerator\List.cshtml


添加:


@ using System.Collections.Generic;

@using System.Linq;


所以'标题'看起来像:


@ inherits Microsoft.VisualStudio.Web.CodeGeneration.Templating.RazorTemplateBase

@using Microsoft.VisualStudio.Web.CodeGeneration.EntityFrameworkCore

@using System.Collections.Generic

@using System.Linq

@@ model @GetEnumerableTypeExpression(Model.ViewDataTypeName)


然后进行以下替换:


IEnumerable< PropertyMetadata>  var properties = Model.ModelMetadata.Properties;


我没有必要改变其他视图模板,我也不使用其他控制器模板。


如果以上不起作用,请重定向到这个适当的论坛:
https://forums.asp.net/1255.aspx/1?ASP+NET+Core 并开始一个新的主题以寻求更专业的支持,因为我们的论坛是讨论VS IDE,谢谢你的理解。



最好的问候,


萨拉


Have an Asp.net core 1.1 Mvc app that I converted to 2.0 that includes a custom Templates/ folder.  When I attempt to add a controller w EF actions, I get the following error:



I assume there are updated templates for core 2.0 but don't know where to find them??

解决方案

Hi Alex,

Welcome to the MSDN forum.

Refer to the error message, please check this similar issue: Migration 1.1 to 2.0 : Scaffold multiple problems and try the following solution that provided by NicolasREY:

I checked the differences, and here are the mandatory modifications:

Templates\ControllerGenerator\MvcControllerWithContext.cshtml

Add:

@using System.Collections.Generic;
@using System.Linq;

in addition of:

using System.Collections.Generic;
using System.Linq;

So the 'header' looks like :

@inherits Microsoft.VisualStudio.Web.CodeGeneration.Templating.RazorTemplateBase
@using System.Collections.Generic;
@using System.Linq;
using System;
using System.Collections.Generic;
using System.Linq;
using System.Threading.Tasks;
using Microsoft.AspNetCore.Mvc;
using Microsoft.AspNetCore.Mvc.Rendering;
using Microsoft.EntityFrameworkCore;

Templates\ViewGenerator\List.cshtml

Add :

@using System.Collections.Generic;
@using System.Linq;

so the 'header' looks like :

@inherits Microsoft.VisualStudio.Web.CodeGeneration.Templating.RazorTemplateBase
@using Microsoft.VisualStudio.Web.CodeGeneration.EntityFrameworkCore
@using System.Collections.Generic
@using System.Linq
@@model @GetEnumerableTypeExpression(Model.ViewDataTypeName)

Then make the following replacement :

IEnumerable<PropertyMetadata> var properties = Model.ModelMetadata.Properties;

I didn't have to change anything else to my other view templates, and I don't use other controller templates.

If the above not works, please redirect to this appropriate forum: https://forums.asp.net/1255.aspx/1?ASP+NET+Core and start a new thread to seek for a more professional support, since our forum is to discuss the VS IDE, thank you for your understanding.

Best regards,

Sara


这篇关于Asp.Net核心2.0 Mvc应用程序错误的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆