简体   繁体   中英

How to enable runtime scaffolding in EF Core

Creating dynamic ASP.NET MVC EF Core application with Npgsql EF Core provider.

I tried to implement runtime scaffolding as described in

https://medium.com/@zaikinsr/roslyn-ef-core-runtime-dbcontext-constructing-285a9d67bc87

In project.config file

  <PackageReference Include="Microsoft.EntityFrameworkCore.Design" Version="5.0.2">
  <PrivateAssets>all</PrivateAssets>
  <IncludeAssets>runtime; build; native; contentfiles; analyzers; buildtransitive</IncludeAssets>
</PackageReference>

is changed to

<PackageReference Include="Microsoft.EntityFrameworkCore.Design" Version="5.0.2"/>

After that yellow warning icons appear in Visual Studio Solution Explore Dependecies tree:

在此处输入图像描述

Build and package manager windows do not contain any warnings. How to find warning message related to this icon? How to fix this?

Which is proper way to use scaffold in runtime?

When I tried your steps on my side with Asp Net Core 3.1 MVC project, I did not face the same situation with the yellow icon.

Please try the following steps:

  1. clean nuget caches first or just delete all files under C:\Users\Administrator\.nuget\packages .

    Then , close VS, , delete .vs hidden folder under the solution folder, bin and obj folder of your project.

    After that, restart your project to test again.

  2. add dotnet restore under Project Properties --> Build Events --> Pre-build event command line , then build your project to test again.

  3. create a new Asp Net Core project to test again.

The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM