ASP.NET CORE MVC SCAFFOLD
A simple toold that will help you generate your controllers and views the same way Visual Studio IDE on Windows do.
This tools requires you to include the following packages in your .csproj file before you use it. You need to follow the steps below to be able to use it:
- After creating your project open the
.csproj file and add the following packages to it
<PackageReference Include="Microsoft.VisualStudio.Web.CodeGeneration.Design" Version="1.1.1" />
<PackageReference Include="Microsoft.Composition" Version="1.0.30" ExcludeAssets="All" />
<PackageReference Include="System.Composition" Version="1.0.31" />
dotnet restore and make sure your file restoration completes with no errors.
- Now you are ready to use the tool
Microsoft.VisualStudio.Web.CodeGeneration.Design will help you scaffold your application the same way you do in Visual Studio IDE.
System.Composition will fix and error while trying to restore the
- Make sure your ApplicationDbContext is present.
- Create the appropriate Model Class
- Open the command palette using the
cmd+shift+p on MacOS or
ctrl+shift+p on windows
- You will be asked to enter your controller name, model name, db context class name and finally the project path
- By fulfilling the requirements a terminal window will show up with the process of scaffolding controller and views then add a new migration and finally updates your database
- Finally build and run your application