新的语言功能实现了缩写默认关键字的选项。
public void GenericMethod<T>(T responseObject = default)
{
//Your code here
}
与其使用旧的
public void GenericMethod<T>(T responseObject = default(T))
{
//Your code here
}
使用新的简写方式时,我们遇到了一个bug,即无法在dotnet core中为视图或控制器搭建脚手架,会出现错误提示"There was an error running the selected code generator: Could not get the reflection type for DbContext : ...."。
通过回滚到实现“default”的旧方法,可以消除这个错误。
目前为止,我们只遇到了使用"default"关键字的新方法出现问题,但我想类似的新语言特性可能也会出现问题。
这并不是一个问题。我们只是认为传播这个bug的消息很有意义,因为没有任何文章涉及到这个问题。
Visual Studio版本:Visual Studio 2019
目标框架:.NET Core 2.2
编辑:这不是EF的问题。如果你尝试在没有dbContext的情况下为使用Model类(FooClass)的视图搭建脚手架,错误提示将变成:"Could not get the reflection type for Model: FooClass"。