Could not get the reflection type for DbContext

前端 未结 5 1319
慢半拍i
慢半拍i 2020-12-10 01:47

When scaffolding a controller in ASP Core 2.0 VS 2017 I get the following:

Could not get the reflection type for DbContext :

BE.Data.ApplicationDb

5条回答
  •  無奈伤痛
    2020-12-10 02:19

    I had this issue too, when I was using the new C#7 feature (expression bodied members and Throw expressions) but by replacing my code with it's equivalent in C#6 it didn't give me that error anymore. Try to test your project without any C#7 new feature and probably it should works fine. I'm not sure what is the reason but I think The Roslyn packages that scaffolding depends on does not support C#7 new features yet.

    As a workaround to let scaffolding works with C#7 I think you can by doing the following:

    1. Install (or update) NuGet package Microsoft.CodeAnalysis.CSharp.Workspaces version 2.0.0 or higher
    2. And then retry to scaffolding again

提交回复
热议问题