{"id":4146,"date":"2019-06-27T07:18:59","date_gmt":"2019-06-27T07:18:59","guid":{"rendered":"http:\/\/myprojects.advchaweb.com\/?p=4146"},"modified":"2019-06-27T08:23:25","modified_gmt":"2019-06-27T08:23:25","slug":"developing-asp-net-core-project-razor-pages","status":"publish","type":"post","link":"https:\/\/myprojects.advchaweb.com\/index.php\/2019\/06\/27\/developing-asp-net-core-project-razor-pages\/","title":{"rendered":"Developing ASP.NET Core Project With VS Code &#8211; Razor Pages"},"content":{"rendered":"<p>ref: https:\/\/docs.microsoft.com\/en-us\/aspnet\/core\/tutorials\/razor-pages\/razor-pages-start?view=aspnetcore-2.2&amp;tabs=visual-studio-code<\/p>\n<p>Create a Razor Pages web app<br \/>\nType in the terminal<\/p>\n<pre class=\"lang:default decode:true \">teddy@teddy:~\/Documents\/dotnet$ dotnet new webApp -o RazorPagesMovie\r\nThe template \"ASP.NET Core Web App\" was created successfully.\r\nThis template contains technologies from parties other than Microsoft, see https:\/\/aka.ms\/aspnetcore-template-3pn-210 for details.\r\n\r\nProcessing post-creation actions...\r\nRunning 'dotnet restore' on RazorPagesMovie\/RazorPagesMovie.csproj...\r\n  Restore completed in 476.81 ms for \/home\/teddy\/Documents\/dotnet\/RazorPagesMovie\/RazorPagesMovie.csproj.\r\n\r\nRestore succeeded.<\/pre>\n<p>Open it on VSCode<\/p>\n<pre class=\"lang:default decode:true \">teddy@teddy:~\/Documents\/dotnet$ code -r RazorPagesMovie<\/pre>\n<p>After the status bar&#8217;s OmniSharp flame icon turns green, a dialog asks\u00a0Required assets to build and debug are missing from &#8216;RazorPagesMovie&#8217;. Add them?\u00a0Select\u00a0Yes.<\/p>\n<p>A\u00a0.vscode\u00a0directory, containing\u00a0launch.json\u00a0and\u00a0tasks.json\u00a0files, is added to the project&#8217;s root directory.<\/p>\n<p>Run the app<br \/>\nOn the VSCode, open the terminal by pressing CTRL + ~<br \/>\nthen type<\/p>\n<pre class=\"lang:default decode:true\">teddy@teddy:~\/Documents\/dotnet\/RazorPagesMovie$ dotnet dev-certs https\r\nA valid HTTPS certificate is already present.<\/pre>\n<p>NOTE: I FOUND THIS COMMAND: &#8216;dotnet dev-certs https &#8211;trust&#8217; IS NOT WORKING<br \/>\nThen Press Ctrl-F5 to run without the debugger. It&#8217;ll open the browser automatically with this url: https:\/\/localhost:5001\/<\/p>\n<p>Add a data model<br \/>\nAdd a folder named\u00a0Models.<br \/>\nAdd a class to the\u00a0Models\u00a0folder named\u00a0Movie.cs.<br \/>\nAdd the following properties to the\u00a0Movie\u00a0class:<\/p>\n<pre class=\"lang:default decode:true \">using System;\r\nusing System.ComponentModel.DataAnnotations;\r\n\r\nnamespace RazorPagesMovie.Models\r\n{\r\n    public class Movie\r\n    {\r\n        public int ID {get; set;}\r\n        public string Title {get; set;}\r\n\r\n        [DataType(DataType.Date)]\r\n        public DateTime ReleaseDate {get; set;}\r\n        public string Genre {get; set;}\r\n        public decimal Price {get; set;}\r\n    }\r\n}<\/pre>\n<p>Add a database context class<br \/>\nAdd the following\u00a0RazorPagesMovieContext\u00a0class to the\u00a0Data\u00a0folder:<\/p>\n<pre class=\"lang:default decode:true \">using Microsoft.EntityFrameworkCore;\r\n\r\nnamespace RazorPagesMovie.Models\r\n{\r\n    public class RazorPagesMovieContext : DbContext\r\n    {\r\n        public RazorPagesMovieContext(DbContextOptions&lt;RazorPagesMovieContext&gt; options) : base(options)\r\n        {\r\n\r\n        }\r\n\r\n        public DbSet&lt;RazorPagesMovie.Models.Movie&gt; Movie {get; set;}\r\n    }\r\n}<\/pre>\n<p>Add a database connection string<br \/>\nAdd a connection string to the\u00a0appsettings.json\u00a0file as shown in the following highlighted code:<\/p>\n<pre class=\"lang:default decode:true \">{\r\n  \"Logging\": {\r\n    \"LogLevel\": {\r\n      \"Default\": \"Warning\"\r\n    }\r\n  },\r\n  \"AllowedHosts\": \"*\",\r\n  \"ConnectionStrings\": {\r\n    \"MovieContext\": \"DataSource=MvcMovie.db\"\r\n  }\r\n}\r\n<\/pre>\n<p>Add required NuGet packages<br \/>\nRun the following .NET Core CLI command to add SQLite and CodeGeneration.Design to the project:<\/p>\n<pre class=\"lang:default decode:true \">dotnet add package Microsoft.EntityFrameworkCore.SQLite\r\ndotnet add package Microsoft.VisualStudio.Web.CodeGeneration.Design\r\ndotnet add package Microsoft.EntityFrameworkCore.Design<\/pre>\n<pre class=\"lang:default decode:true \">teddy@teddy:~\/Documents\/dotnet\/RazorPagesMovie$ dotnet add package Microsoft.EntityFrameworkCore.SQLite\r\n  Writing \/tmp\/tmp6s15JK.tmp\r\ninfo : Adding PackageReference for package 'Microsoft.EntityFrameworkCore.SQLite' into project '\/home\/teddy\/Documents\/dotnet\/RazorPagesMovie\/RazorPagesMovie.csproj'.\r\ninfo : Restoring packages for \/home\/teddy\/Documents\/dotnet\/RazorPagesMovie\/RazorPagesMovie.csproj...\r\ninfo :   GET https:\/\/api.nuget.org\/v3-flatcontainer\/microsoft.entityframeworkcore.sqlite\/index.json\r\ninfo :   OK https:\/\/api.nuget.org\/v3-flatcontainer\/microsoft.entityframeworkcore.sqlite\/index.json 1010ms\r\ninfo :   GET https:\/\/api.nuget.org\/v3-flatcontainer\/microsoft.entityframeworkcore.sqlite\/2.2.4\/microsoft.entityframeworkcore.sqlite.2.2.4.nupkg\r\ninfo :   OK https:\/\/api.nuget.org\/v3-flatcontainer\/microsoft.entityframeworkcore.sqlite\/2.2.4\/microsoft.entityframeworkcore.sqlite.2.2.4.nupkg 34ms\r\ninfo :   GET https:\/\/api.nuget.org\/v3-flatcontainer\/microsoft.entityframeworkcore.sqlite.core\/index.json\r\ninfo :   GET https:\/\/api.nuget.org\/v3-flatcontainer\/sqlitepclraw.bundle_green\/index.json\r\ninfo :   OK https:\/\/api.nuget.org\/v3-flatcontainer\/microsoft.entityframeworkcore.sqlite.core\/index.json 998ms\r\ninfo :   GET https:\/\/api.nuget.org\/v3-flatcontainer\/microsoft.entityframeworkcore.sqlite.core\/2.2.4\/microsoft.entityframeworkcore.sqlite.core.2.2.4.nupkg\r\ninfo :   OK https:\/\/api.nuget.org\/v3-flatcontainer\/microsoft.entityframeworkcore.sqlite.core\/2.2.4\/microsoft.entityframeworkcore.sqlite.core.2.2.4.nupkg 32ms\r\ninfo :   GET https:\/\/api.nuget.org\/v3-flatcontainer\/microsoft.entityframeworkcore.relational\/index.json\r\ninfo :   GET https:\/\/api.nuget.org\/v3-flatcontainer\/microsoft.data.sqlite.core\/index.json\r\ninfo :   OK https:\/\/api.nuget.org\/v3-flatcontainer\/sqlitepclraw.bundle_green\/index.json 1136ms\r\ninfo :   GET https:\/\/api.nuget.org\/v3-flatcontainer\/sqlitepclraw.bundle_green\/1.1.12\/sqlitepclraw.bundle_green.1.1.12.nupkg\r\ninfo :   OK https:\/\/api.nuget.org\/v3-flatcontainer\/sqlitepclraw.bundle_green\/1.1.12\/sqlitepclraw.bundle_green.1.1.12.nupkg 33ms\r\ninfo :   GET https:\/\/api.nuget.org\/v3-flatcontainer\/sqlitepclraw.core\/index.json\r\ninfo :   GET https:\/\/api.nuget.org\/v3-flatcontainer\/sqlitepclraw.provider.e_sqlite3.netstandard11\/index.json\r\ninfo :   GET https:\/\/api.nuget.org\/v3-flatcontainer\/sqlitepclraw.lib.e_sqlite3.v110_xp\/index.json\r\ninfo :   GET https:\/\/api.nuget.org\/v3-flatcontainer\/sqlitepclraw.lib.e_sqlite3.osx\/index.json\r\ninfo :   GET https:\/\/api.nuget.org\/v3-flatcontainer\/sqlitepclraw.lib.e_sqlite3.linux\/index.json\r\ninfo :   OK https:\/\/api.nuget.org\/v3-flatcontainer\/microsoft.entityframeworkcore.relational\/index.json 1002ms\r\ninfo :   GET https:\/\/api.nuget.org\/v3-flatcontainer\/microsoft.entityframeworkcore.relational\/2.2.4\/microsoft.entityframeworkcore.relational.2.2.4.nupkg\r\ninfo :   OK https:\/\/api.nuget.org\/v3-flatcontainer\/microsoft.entityframeworkcore.relational\/2.2.4\/microsoft.entityframeworkcore.relational.2.2.4.nupkg 31ms\r\ninfo :   OK https:\/\/api.nuget.org\/v3-flatcontainer\/microsoft.data.sqlite.core\/index.json 1100ms\r\ninfo :   GET https:\/\/api.nuget.org\/v3-flatcontainer\/microsoft.data.sqlite.core\/2.2.4\/microsoft.data.sqlite.core.2.2.4.nupkg\r\ninfo :   GET https:\/\/api.nuget.org\/v3-flatcontainer\/microsoft.entityframeworkcore\/index.json\r\ninfo :   OK https:\/\/api.nuget.org\/v3-flatcontainer\/microsoft.data.sqlite.core\/2.2.4\/microsoft.data.sqlite.core.2.2.4.nupkg 33ms\r\ninfo :   OK https:\/\/api.nuget.org\/v3-flatcontainer\/sqlitepclraw.lib.e_sqlite3.v110_xp\/index.json 1120ms\r\ninfo :   GET https:\/\/api.nuget.org\/v3-flatcontainer\/sqlitepclraw.lib.e_sqlite3.v110_xp\/1.1.12\/sqlitepclraw.lib.e_sqlite3.v110_xp.1.1.12.nupkg\r\ninfo :   OK https:\/\/api.nuget.org\/v3-flatcontainer\/sqlitepclraw.lib.e_sqlite3.linux\/index.json 1122ms\r\ninfo :   GET https:\/\/api.nuget.org\/v3-flatcontainer\/sqlitepclraw.lib.e_sqlite3.linux\/1.1.12\/sqlitepclraw.lib.e_sqlite3.linux.1.1.12.nupkg\r\ninfo :   OK https:\/\/api.nuget.org\/v3-flatcontainer\/sqlitepclraw.lib.e_sqlite3.osx\/index.json 1123ms\r\ninfo :   GET https:\/\/api.nuget.org\/v3-flatcontainer\/sqlitepclraw.lib.e_sqlite3.osx\/1.1.12\/sqlitepclraw.lib.e_sqlite3.osx.1.1.12.nupkg\r\ninfo :   OK https:\/\/api.nuget.org\/v3-flatcontainer\/sqlitepclraw.provider.e_sqlite3.netstandard11\/index.json 1146ms\r\ninfo :   GET https:\/\/api.nuget.org\/v3-flatcontainer\/sqlitepclraw.provider.e_sqlite3.netstandard11\/1.1.12\/sqlitepclraw.provider.e_sqlite3.netstandard11.1.1.12.nupkg\r\ninfo :   OK https:\/\/api.nuget.org\/v3-flatcontainer\/sqlitepclraw.lib.e_sqlite3.v110_xp\/1.1.12\/sqlitepclraw.lib.e_sqlite3.v110_xp.1.1.12.nupkg 32ms\r\ninfo :   OK https:\/\/api.nuget.org\/v3-flatcontainer\/sqlitepclraw.lib.e_sqlite3.linux\/1.1.12\/sqlitepclraw.lib.e_sqlite3.linux.1.1.12.nupkg 33ms\r\ninfo :   OK https:\/\/api.nuget.org\/v3-flatcontainer\/sqlitepclraw.lib.e_sqlite3.osx\/1.1.12\/sqlitepclraw.lib.e_sqlite3.osx.1.1.12.nupkg 36ms\r\ninfo :   OK https:\/\/api.nuget.org\/v3-flatcontainer\/sqlitepclraw.provider.e_sqlite3.netstandard11\/1.1.12\/sqlitepclraw.provider.e_sqlite3.netstandard11.1.1.12.nupkg 31ms\r\ninfo :   OK https:\/\/api.nuget.org\/v3-flatcontainer\/sqlitepclraw.core\/index.json 1476ms\r\ninfo :   GET https:\/\/api.nuget.org\/v3-flatcontainer\/sqlitepclraw.core\/1.1.12\/sqlitepclraw.core.1.1.12.nupkg\r\ninfo :   OK https:\/\/api.nuget.org\/v3-flatcontainer\/sqlitepclraw.core\/1.1.12\/sqlitepclraw.core.1.1.12.nupkg 139ms\r\ninfo :   OK https:\/\/api.nuget.org\/v3-flatcontainer\/microsoft.entityframeworkcore\/index.json 1026ms\r\ninfo :   GET https:\/\/api.nuget.org\/v3-flatcontainer\/microsoft.entityframeworkcore\/2.2.4\/microsoft.entityframeworkcore.2.2.4.nupkg\r\ninfo :   OK https:\/\/api.nuget.org\/v3-flatcontainer\/microsoft.entityframeworkcore\/2.2.4\/microsoft.entityframeworkcore.2.2.4.nupkg 158ms\r\ninfo :   GET https:\/\/api.nuget.org\/v3-flatcontainer\/microsoft.entityframeworkcore.abstractions\/index.json\r\ninfo :   GET https:\/\/api.nuget.org\/v3-flatcontainer\/microsoft.entityframeworkcore.analyzers\/index.json\r\ninfo :   OK https:\/\/api.nuget.org\/v3-flatcontainer\/microsoft.entityframeworkcore.abstractions\/index.json 997ms\r\ninfo :   GET https:\/\/api.nuget.org\/v3-flatcontainer\/microsoft.entityframeworkcore.abstractions\/2.2.4\/microsoft.entityframeworkcore.abstractions.2.2.4.nupkg\r\ninfo :   OK https:\/\/api.nuget.org\/v3-flatcontainer\/microsoft.entityframeworkcore.analyzers\/index.json 1003ms\r\ninfo :   GET https:\/\/api.nuget.org\/v3-flatcontainer\/microsoft.entityframeworkcore.analyzers\/2.2.4\/microsoft.entityframeworkcore.analyzers.2.2.4.nupkg\r\ninfo :   OK https:\/\/api.nuget.org\/v3-flatcontainer\/microsoft.entityframeworkcore.abstractions\/2.2.4\/microsoft.entityframeworkcore.abstractions.2.2.4.nupkg 33ms\r\ninfo :   OK https:\/\/api.nuget.org\/v3-flatcontainer\/microsoft.entityframeworkcore.analyzers\/2.2.4\/microsoft.entityframeworkcore.analyzers.2.2.4.nupkg 33ms\r\ninfo : Installing Microsoft.EntityFrameworkCore.Analyzers 2.2.4.\r\ninfo : Installing Microsoft.EntityFrameworkCore.Abstractions 2.2.4.\r\ninfo : Installing Microsoft.EntityFrameworkCore 2.2.4.\r\ninfo : Installing SQLitePCLRaw.lib.e_sqlite3.linux 1.1.12.\r\ninfo : Installing SQLitePCLRaw.lib.e_sqlite3.osx 1.1.12.\r\ninfo : Installing SQLitePCLRaw.lib.e_sqlite3.v110_xp 1.1.12.\r\ninfo : Installing SQLitePCLRaw.core 1.1.12.\r\ninfo : Installing SQLitePCLRaw.provider.e_sqlite3.netstandard11 1.1.12.\r\ninfo : Installing Microsoft.EntityFrameworkCore.Relational 2.2.4.\r\ninfo : Installing Microsoft.Data.Sqlite.Core 2.2.4.\r\ninfo : Installing SQLitePCLRaw.bundle_green 1.1.12.\r\ninfo : Installing Microsoft.EntityFrameworkCore.Sqlite.Core 2.2.4.\r\ninfo : Installing Microsoft.EntityFrameworkCore.Sqlite 2.2.4.\r\ninfo : Package 'Microsoft.EntityFrameworkCore.SQLite' is compatible with all the specified frameworks in project '\/home\/teddy\/Documents\/dotnet\/RazorPagesMovie\/RazorPagesMovie.csproj'.\r\ninfo : PackageReference for package 'Microsoft.EntityFrameworkCore.SQLite' version '2.2.4' added to file '\/home\/teddy\/Documents\/dotnet\/RazorPagesMovie\/RazorPagesMovie.csproj'.\r\ninfo : Committing restore...\r\ninfo : Writing assets file to disk. Path: \/home\/teddy\/Documents\/dotnet\/RazorPagesMovie\/obj\/project.assets.json\r\nlog  : Restore completed in 9.79 sec for \/home\/teddy\/Documents\/dotnet\/RazorPagesMovie\/RazorPagesMovie.csproj.\r\nteddy@teddy:~\/Documents\/dotnet\/RazorPagesMovie$ dotnet add package Microsoft.VisualStudio.Web.CodeGeneration.Design\r\n  Writing \/tmp\/tmpUPJJcI.tmp\r\ninfo : Adding PackageReference for package 'Microsoft.VisualStudio.Web.CodeGeneration.Design' into project '\/home\/teddy\/Documents\/dotnet\/RazorPagesMovie\/RazorPagesMovie.csproj'.\r\ninfo : Restoring packages for \/home\/teddy\/Documents\/dotnet\/RazorPagesMovie\/RazorPagesMovie.csproj...\r\ninfo :   GET https:\/\/api.nuget.org\/v3-flatcontainer\/microsoft.visualstudio.web.codegeneration.design\/index.json\r\ninfo :   OK https:\/\/api.nuget.org\/v3-flatcontainer\/microsoft.visualstudio.web.codegeneration.design\/index.json 1296ms\r\ninfo :   GET https:\/\/api.nuget.org\/v3-flatcontainer\/microsoft.visualstudio.web.codegeneration.design\/2.2.3\/microsoft.visualstudio.web.codegeneration.design.2.2.3.nupkg\r\ninfo :   OK https:\/\/api.nuget.org\/v3-flatcontainer\/microsoft.visualstudio.web.codegeneration.design\/2.2.3\/microsoft.visualstudio.web.codegeneration.design.2.2.3.nupkg 35ms\r\ninfo :   GET https:\/\/api.nuget.org\/v3-flatcontainer\/microsoft.visualstudio.web.codegenerators.mvc\/index.json\r\ninfo :   OK https:\/\/api.nuget.org\/v3-flatcontainer\/microsoft.visualstudio.web.codegenerators.mvc\/index.json 1004ms\r\ninfo :   GET https:\/\/api.nuget.org\/v3-flatcontainer\/microsoft.visualstudio.web.codegenerators.mvc\/2.2.3\/microsoft.visualstudio.web.codegenerators.mvc.2.2.3.nupkg\r\ninfo :   OK https:\/\/api.nuget.org\/v3-flatcontainer\/microsoft.visualstudio.web.codegenerators.mvc\/2.2.3\/microsoft.visualstudio.web.codegenerators.mvc.2.2.3.nupkg 34ms\r\ninfo :   GET https:\/\/api.nuget.org\/v3-flatcontainer\/microsoft.visualstudio.web.codegeneration\/index.json\r\ninfo :   OK https:\/\/api.nuget.org\/v3-flatcontainer\/microsoft.visualstudio.web.codegeneration\/index.json 1001ms\r\ninfo :   GET https:\/\/api.nuget.org\/v3-flatcontainer\/microsoft.visualstudio.web.codegeneration\/2.2.3\/microsoft.visualstudio.web.codegeneration.2.2.3.nupkg\r\ninfo :   OK https:\/\/api.nuget.org\/v3-flatcontainer\/microsoft.visualstudio.web.codegeneration\/2.2.3\/microsoft.visualstudio.web.codegeneration.2.2.3.nupkg 31ms\r\ninfo :   GET https:\/\/api.nuget.org\/v3-flatcontainer\/microsoft.visualstudio.web.codegeneration.entityframeworkcore\/index.json\r\ninfo :   OK https:\/\/api.nuget.org\/v3-flatcontainer\/microsoft.visualstudio.web.codegeneration.entityframeworkcore\/index.json 1001ms\r\ninfo :   GET https:\/\/api.nuget.org\/v3-flatcontainer\/microsoft.visualstudio.web.codegeneration.entityframeworkcore\/2.2.3\/microsoft.visualstudio.web.codegeneration.entityframeworkcore.2.2.3.nupkg\r\ninfo :   OK https:\/\/api.nuget.org\/v3-flatcontainer\/microsoft.visualstudio.web.codegeneration.entityframeworkcore\/2.2.3\/microsoft.visualstudio.web.codegeneration.entityframeworkcore.2.2.3.nupkg 32ms\r\ninfo :   GET https:\/\/api.nuget.org\/v3-flatcontainer\/microsoft.visualstudio.web.codegeneration.core\/index.json\r\ninfo :   OK https:\/\/api.nuget.org\/v3-flatcontainer\/microsoft.visualstudio.web.codegeneration.core\/index.json 1004ms\r\ninfo :   GET https:\/\/api.nuget.org\/v3-flatcontainer\/microsoft.visualstudio.web.codegeneration.core\/2.2.3\/microsoft.visualstudio.web.codegeneration.core.2.2.3.nupkg\r\ninfo :   OK https:\/\/api.nuget.org\/v3-flatcontainer\/microsoft.visualstudio.web.codegeneration.core\/2.2.3\/microsoft.visualstudio.web.codegeneration.core.2.2.3.nupkg 34ms\r\ninfo :   GET https:\/\/api.nuget.org\/v3-flatcontainer\/microsoft.visualstudio.web.codegeneration.templating\/index.json\r\ninfo :   OK https:\/\/api.nuget.org\/v3-flatcontainer\/microsoft.visualstudio.web.codegeneration.templating\/index.json 994ms\r\ninfo :   GET https:\/\/api.nuget.org\/v3-flatcontainer\/microsoft.visualstudio.web.codegeneration.templating\/2.2.3\/microsoft.visualstudio.web.codegeneration.templating.2.2.3.nupkg\r\ninfo :   OK https:\/\/api.nuget.org\/v3-flatcontainer\/microsoft.visualstudio.web.codegeneration.templating\/2.2.3\/microsoft.visualstudio.web.codegeneration.templating.2.2.3.nupkg 31ms\r\ninfo :   GET https:\/\/api.nuget.org\/v3-flatcontainer\/microsoft.visualstudio.web.codegeneration.utils\/index.json\r\ninfo :   OK https:\/\/api.nuget.org\/v3-flatcontainer\/microsoft.visualstudio.web.codegeneration.utils\/index.json 1002ms\r\ninfo :   GET https:\/\/api.nuget.org\/v3-flatcontainer\/microsoft.visualstudio.web.codegeneration.utils\/2.2.3\/microsoft.visualstudio.web.codegeneration.utils.2.2.3.nupkg\r\ninfo :   OK https:\/\/api.nuget.org\/v3-flatcontainer\/microsoft.visualstudio.web.codegeneration.utils\/2.2.3\/microsoft.visualstudio.web.codegeneration.utils.2.2.3.nupkg 31ms\r\ninfo :   GET https:\/\/api.nuget.org\/v3-flatcontainer\/microsoft.visualstudio.web.codegeneration.contracts\/index.json\r\ninfo :   GET https:\/\/api.nuget.org\/v3-flatcontainer\/microsoft.codeanalysis.csharp.workspaces\/index.json\r\ninfo :   GET https:\/\/api.nuget.org\/v3-flatcontainer\/nuget.frameworks\/index.json\r\ninfo :   OK https:\/\/api.nuget.org\/v3-flatcontainer\/microsoft.visualstudio.web.codegeneration.contracts\/index.json 1000ms\r\ninfo :   GET https:\/\/api.nuget.org\/v3-flatcontainer\/microsoft.visualstudio.web.codegeneration.contracts\/2.2.3\/microsoft.visualstudio.web.codegeneration.contracts.2.2.3.nupkg\r\ninfo :   OK https:\/\/api.nuget.org\/v3-flatcontainer\/microsoft.visualstudio.web.codegeneration.contracts\/2.2.3\/microsoft.visualstudio.web.codegeneration.contracts.2.2.3.nupkg 31ms\r\ninfo :   OK https:\/\/api.nuget.org\/v3-flatcontainer\/microsoft.codeanalysis.csharp.workspaces\/index.json 1106ms\r\ninfo :   GET https:\/\/api.nuget.org\/v3-flatcontainer\/microsoft.codeanalysis.csharp.workspaces\/2.8.0\/microsoft.codeanalysis.csharp.workspaces.2.8.0.nupkg\r\ninfo :   OK https:\/\/api.nuget.org\/v3-flatcontainer\/nuget.frameworks\/index.json 1132ms\r\ninfo :   GET https:\/\/api.nuget.org\/v3-flatcontainer\/nuget.frameworks\/4.7.0\/nuget.frameworks.4.7.0.nupkg\r\ninfo :   OK https:\/\/api.nuget.org\/v3-flatcontainer\/microsoft.codeanalysis.csharp.workspaces\/2.8.0\/microsoft.codeanalysis.csharp.workspaces.2.8.0.nupkg 35ms\r\ninfo :   OK https:\/\/api.nuget.org\/v3-flatcontainer\/nuget.frameworks\/4.7.0\/nuget.frameworks.4.7.0.nupkg 39ms\r\ninfo :   GET https:\/\/api.nuget.org\/v3-flatcontainer\/microsoft.codeanalysis.workspaces.common\/index.json\r\ninfo :   OK https:\/\/api.nuget.org\/v3-flatcontainer\/microsoft.codeanalysis.workspaces.common\/index.json 1029ms\r\ninfo :   GET https:\/\/api.nuget.org\/v3-flatcontainer\/microsoft.codeanalysis.workspaces.common\/2.8.0\/microsoft.codeanalysis.workspaces.common.2.8.0.nupkg\r\ninfo :   OK https:\/\/api.nuget.org\/v3-flatcontainer\/microsoft.codeanalysis.workspaces.common\/2.8.0\/microsoft.codeanalysis.workspaces.common.2.8.0.nupkg 32ms\r\ninfo :   GET https:\/\/api.nuget.org\/v3-flatcontainer\/system.composition\/index.json\r\ninfo :   GET https:\/\/api.nuget.org\/v3-flatcontainer\/system.linq.parallel\/index.json\r\ninfo :   OK https:\/\/api.nuget.org\/v3-flatcontainer\/system.composition\/index.json 1004ms\r\ninfo :   GET https:\/\/api.nuget.org\/v3-flatcontainer\/system.composition\/1.0.31\/system.composition.1.0.31.nupkg\r\ninfo :   OK https:\/\/api.nuget.org\/v3-flatcontainer\/system.linq.parallel\/index.json 1006ms\r\ninfo :   GET https:\/\/api.nuget.org\/v3-flatcontainer\/system.linq.parallel\/4.3.0\/system.linq.parallel.4.3.0.nupkg\r\ninfo :   OK https:\/\/api.nuget.org\/v3-flatcontainer\/system.composition\/1.0.31\/system.composition.1.0.31.nupkg 32ms\r\ninfo :   GET https:\/\/api.nuget.org\/v3-flatcontainer\/system.composition.attributedmodel\/index.json\r\ninfo :   GET https:\/\/api.nuget.org\/v3-flatcontainer\/system.composition.convention\/index.json\r\ninfo :   GET https:\/\/api.nuget.org\/v3-flatcontainer\/system.composition.hosting\/index.json\r\ninfo :   GET https:\/\/api.nuget.org\/v3-flatcontainer\/system.composition.runtime\/index.json\r\ninfo :   GET https:\/\/api.nuget.org\/v3-flatcontainer\/system.composition.typedparts\/index.json\r\ninfo :   OK https:\/\/api.nuget.org\/v3-flatcontainer\/system.linq.parallel\/4.3.0\/system.linq.parallel.4.3.0.nupkg 39ms\r\ninfo :   OK https:\/\/api.nuget.org\/v3-flatcontainer\/system.composition.attributedmodel\/index.json 997ms\r\ninfo :   GET https:\/\/api.nuget.org\/v3-flatcontainer\/system.composition.attributedmodel\/1.0.31\/system.composition.attributedmodel.1.0.31.nupkg\r\ninfo :   OK https:\/\/api.nuget.org\/v3-flatcontainer\/system.composition.convention\/index.json 1042ms\r\ninfo :   GET https:\/\/api.nuget.org\/v3-flatcontainer\/system.composition.convention\/1.0.31\/system.composition.convention.1.0.31.nupkg\r\ninfo :   OK https:\/\/api.nuget.org\/v3-flatcontainer\/system.composition.attributedmodel\/1.0.31\/system.composition.attributedmodel.1.0.31.nupkg 76ms\r\ninfo :   OK https:\/\/api.nuget.org\/v3-flatcontainer\/system.composition.convention\/1.0.31\/system.composition.convention.1.0.31.nupkg 35ms\r\ninfo :   OK https:\/\/api.nuget.org\/v3-flatcontainer\/system.composition.typedparts\/index.json 1109ms\r\ninfo :   GET https:\/\/api.nuget.org\/v3-flatcontainer\/system.composition.typedparts\/1.0.31\/system.composition.typedparts.1.0.31.nupkg\r\ninfo :   OK https:\/\/api.nuget.org\/v3-flatcontainer\/system.composition.runtime\/index.json 1120ms\r\ninfo :   GET https:\/\/api.nuget.org\/v3-flatcontainer\/system.composition.runtime\/1.0.31\/system.composition.runtime.1.0.31.nupkg\r\ninfo :   OK https:\/\/api.nuget.org\/v3-flatcontainer\/system.composition.typedparts\/1.0.31\/system.composition.typedparts.1.0.31.nupkg 33ms\r\ninfo :   OK https:\/\/api.nuget.org\/v3-flatcontainer\/system.composition.hosting\/index.json 1149ms\r\ninfo :   GET https:\/\/api.nuget.org\/v3-flatcontainer\/system.composition.hosting\/1.0.31\/system.composition.hosting.1.0.31.nupkg\r\ninfo :   OK https:\/\/api.nuget.org\/v3-flatcontainer\/system.composition.runtime\/1.0.31\/system.composition.runtime.1.0.31.nupkg 38ms\r\ninfo :   OK https:\/\/api.nuget.org\/v3-flatcontainer\/system.composition.hosting\/1.0.31\/system.composition.hosting.1.0.31.nupkg 39ms\r\ninfo : Installing System.Composition.Hosting 1.0.31.\r\ninfo : Installing System.Composition.Runtime 1.0.31.\r\ninfo : Installing System.Composition.TypedParts 1.0.31.\r\ninfo : Installing System.Composition.Convention 1.0.31.\r\ninfo : Installing System.Composition.AttributedModel 1.0.31.\r\ninfo : Installing System.Composition 1.0.31.\r\ninfo : Installing System.Linq.Parallel 4.3.0.\r\ninfo : Installing Microsoft.CodeAnalysis.Workspaces.Common 2.8.0.\r\ninfo : Installing Microsoft.CodeAnalysis.CSharp.Workspaces 2.8.0.\r\ninfo : Installing NuGet.Frameworks 4.7.0.\r\ninfo : Installing Microsoft.VisualStudio.Web.CodeGeneration.Contracts 2.2.3.\r\ninfo : Installing Microsoft.VisualStudio.Web.CodeGeneration.Utils 2.2.3.\r\ninfo : Installing Microsoft.VisualStudio.Web.CodeGeneration.Templating 2.2.3.\r\ninfo : Installing Microsoft.VisualStudio.Web.CodeGeneration.Core 2.2.3.\r\ninfo : Installing Microsoft.VisualStudio.Web.CodeGeneration.EntityFrameworkCore 2.2.3.\r\ninfo : Installing Microsoft.VisualStudio.Web.CodeGeneration 2.2.3.\r\ninfo : Installing Microsoft.VisualStudio.Web.CodeGeneration.Design 2.2.3.\r\ninfo : Installing Microsoft.VisualStudio.Web.CodeGenerators.Mvc 2.2.3.\r\ninfo : Package 'Microsoft.VisualStudio.Web.CodeGeneration.Design' is compatible with all the specified frameworks in project '\/home\/teddy\/Documents\/dotnet\/RazorPagesMovie\/RazorPagesMovie.csproj'.\r\ninfo : PackageReference for package 'Microsoft.VisualStudio.Web.CodeGeneration.Design' version '2.2.3' added to file '\/home\/teddy\/Documents\/dotnet\/RazorPagesMovie\/RazorPagesMovie.csproj'.\r\ninfo : Committing restore...\r\ninfo : Generating MSBuild file \/home\/teddy\/Documents\/dotnet\/RazorPagesMovie\/obj\/RazorPagesMovie.csproj.nuget.g.props.\r\ninfo : Writing assets file to disk. Path: \/home\/teddy\/Documents\/dotnet\/RazorPagesMovie\/obj\/project.assets.json\r\nlog  : Restore completed in 14.77 sec for \/home\/teddy\/Documents\/dotnet\/RazorPagesMovie\/RazorPagesMovie.csproj.\r\nteddy@teddy:~\/Documents\/dotnet\/RazorPagesMovie$ dotnet add package Microsoft.EntityFrameworkCore.Design\r\n  Writing \/tmp\/tmprEZck2.tmp\r\ninfo : Adding PackageReference for package 'Microsoft.EntityFrameworkCore.Design' into project '\/home\/teddy\/Documents\/dotnet\/RazorPagesMovie\/RazorPagesMovie.csproj'.\r\ninfo : Restoring packages for \/home\/teddy\/Documents\/dotnet\/RazorPagesMovie\/RazorPagesMovie.csproj...\r\ninfo :   GET https:\/\/api.nuget.org\/v3-flatcontainer\/microsoft.entityframeworkcore.design\/index.json\r\ninfo :   OK https:\/\/api.nuget.org\/v3-flatcontainer\/microsoft.entityframeworkcore.design\/index.json 1252ms\r\ninfo :   GET https:\/\/api.nuget.org\/v3-flatcontainer\/microsoft.entityframeworkcore.design\/2.2.4\/microsoft.entityframeworkcore.design.2.2.4.nupkg\r\ninfo :   OK https:\/\/api.nuget.org\/v3-flatcontainer\/microsoft.entityframeworkcore.design\/2.2.4\/microsoft.entityframeworkcore.design.2.2.4.nupkg 34ms\r\ninfo : Installing Microsoft.EntityFrameworkCore.Design 2.2.4.\r\ninfo : Package 'Microsoft.EntityFrameworkCore.Design' is compatible with all the specified frameworks in project '\/home\/teddy\/Documents\/dotnet\/RazorPagesMovie\/RazorPagesMovie.csproj'.\r\ninfo : PackageReference for package 'Microsoft.EntityFrameworkCore.Design' version '2.2.4' added to file '\/home\/teddy\/Documents\/dotnet\/RazorPagesMovie\/RazorPagesMovie.csproj'.\r\ninfo : Committing restore...\r\ninfo : Generating MSBuild file \/home\/teddy\/Documents\/dotnet\/RazorPagesMovie\/obj\/RazorPagesMovie.csproj.nuget.g.props.\r\ninfo : Writing assets file to disk. Path: \/home\/teddy\/Documents\/dotnet\/RazorPagesMovie\/obj\/project.assets.json\r\nlog  : Restore completed in 2.01 sec for \/home\/teddy\/Documents\/dotnet\/RazorPagesMovie\/RazorPagesMovie.csproj.<\/pre>\n<p>The\u00a0Microsoft.VisualStudio.Web.CodeGeneration.Design\u00a0package is required for scaffolding.<\/p>\n<p>Register the database context<br \/>\nAdd the following\u00a0using\u00a0statements at the top of\u00a0Startup.cs:<\/p>\n<pre class=\"lang:default decode:true \">...\r\nusing RazorPagesMovie.Models;\r\nusing Microsoft.EntityFrameworkCore;\r\n...<\/pre>\n<p>Register the database context with the dependency injection container in Startup.cs in ConfigureServices function:<\/p>\n<pre class=\"lang:default decode:true\">...\r\nnamespace RazorPagesMovie\r\n{\r\n    public class Startup\r\n    {\r\n        ...\r\n\r\n        \/\/ This method gets called by the runtime. Use this method to add services to the container.\r\n        public void ConfigureServices(IServiceCollection services)\r\n        {\r\n            services.Configure&lt;CookiePolicyOptions&gt;(options =&gt;\r\n            {\r\n                ...\r\n            });\r\n\r\n            services.AddDbContext&lt;RazorPagesMovieContext&gt;(options =&gt; \r\n            options.UseSqlite(Configuration.GetConnectionString(\"MovieContext\")));\r\n            services.AddMvc().SetCompatibilityVersion(CompatibilityVersion.Version_2_2);\r\n        }\r\n\r\n        ...\r\n    }\r\n}<\/pre>\n<p>Build the project (&#8216;dotnet build&#8217;) to verify there are no compilation errors.<\/p>\n<pre class=\"lang:default decode:true \">teddy@teddy:~\/Documents\/dotnet\/RazorPagesMovie$ dotnet build\r\nMicrosoft (R) Build Engine version 16.1.76+g14b0a930a7 for .NET Core\r\nCopyright (C) Microsoft Corporation. All rights reserved.\r\n\r\n  Restore completed in 563.27 ms for \/home\/teddy\/Documents\/dotnet\/RazorPagesMovie\/RazorPagesMovie.csproj.\r\n  RazorPagesMovie -&gt; \/home\/teddy\/Documents\/dotnet\/RazorPagesMovie\/bin\/Debug\/netcoreapp2.2\/RazorPagesMovie.dll\r\n  RazorPagesMovie -&gt; \/home\/teddy\/Documents\/dotnet\/RazorPagesMovie\/bin\/Debug\/netcoreapp2.2\/RazorPagesMovie.Views.dll\r\n\r\nBuild succeeded.\r\n    0 Warning(s)\r\n    0 Error(s)\r\n\r\nTime Elapsed 00:00:04.39<\/pre>\n<p>&nbsp;<\/p>\n<p>Scaffold the movie model<br \/>\nIn this section, the movie model is scaffolded. That is, the scaffolding tool produces pages for Create, Read, Update, and Delete (CRUD) operations for the movie model.<br \/>\nInstall the scaffolding tool:<\/p>\n<pre class=\"lang:default decode:true \">teddy@teddy:~\/Documents\/dotnet\/RazorPagesMovie$ dotnet tool install --global dotnet-aspnet-codegenerator\r\nYou can invoke the tool using the following command: dotnet-aspnet-codegenerator\r\nTool 'dotnet-aspnet-codegenerator' (version '2.2.3') was successfully installed.<\/pre>\n<p>Run the scaffolding tool to create CRUD for model &#8216;Movie&#8217;:<\/p>\n<pre class=\"lang:default decode:true \">teddy@teddy:~\/Documents\/dotnet\/RazorPagesMovie$ dotnet aspnet-codegenerator razorpage -m Movie -dc RazorPagesMovieContext -udl -outDir Pages\/Movies --referenceScriptLibraries\r\nBuilding project ...\r\nFinding the generator 'razorpage'...\r\nRunning the generator 'razorpage'...\r\nAttempting to compile the application in memory.\r\nAttempting to figure out the EntityFramework metadata for the model and DbContext: 'Movie'\r\ninfo: Microsoft.EntityFrameworkCore.Infrastructure[10403]\r\n      Entity Framework Core 2.2.4-servicing-10062 initialized 'RazorPagesMovieContext' using provider 'Microsoft.EntityFrameworkCore.Sqlite' with options: None\r\nAdded Razor Page : \/Pages\/Movies\/Create.cshtml\r\nAdded PageModel : \/Pages\/Movies\/Create.cshtml.cs\r\nAdded Razor Page : \/Pages\/Movies\/Edit.cshtml\r\nAdded PageModel : \/Pages\/Movies\/Edit.cshtml.cs\r\nAdded Razor Page : \/Pages\/Movies\/Details.cshtml\r\nAdded PageModel : \/Pages\/Movies\/Details.cshtml.cs\r\nAdded Razor Page : \/Pages\/Movies\/Delete.cshtml\r\nAdded PageModel : \/Pages\/Movies\/Delete.cshtml.cs\r\nAdded Razor Page : \/Pages\/Movies\/Index.cshtml\r\nAdded PageModel : \/Pages\/Movies\/Index.cshtml.cs\r\nRunTime 00:00:06.54<\/pre>\n<p>The scaffold process creates and updates the following files:<\/p>\n<p>Files created<br \/>\nPages\/Movies: Create, Delete, Details, Edit, and Index.<br \/>\nData\/RazorPagesMovieContext.cs<br \/>\nFile updated<br \/>\nStartup.cs<br \/>\nThe created and updated files are explained in the next section.<\/p>\n<p>&nbsp;<\/p>\n","protected":false},"excerpt":{"rendered":"<p>ref: https:\/\/docs.microsoft.com\/en-us\/aspnet\/core\/tutorials\/razor-pages\/razor-pages-start?view=aspnetcore-2.2&amp;tabs=visual-studio-code Create a Razor Pages web app Type in the terminal teddy@teddy:~\/Documents\/dotnet$ dotnet new webApp -o RazorPagesMovie The template &#8220;ASP.NET Core Web App&#8221; was created successfully. This template contains technologies from parties other than Microsoft, see https:\/\/aka.ms\/aspnetcore-template-3pn-210 for details. Processing post-creation actions&#8230; Running &#8216;dotnet restore&#8217; on RazorPagesMovie\/RazorPagesMovie.csproj&#8230; Restore completed in 476.81 ms for \/home\/teddy\/Documents\/dotnet\/RazorPagesMovie\/RazorPagesMovie.csproj. &hellip; <a href=\"https:\/\/myprojects.advchaweb.com\/index.php\/2019\/06\/27\/developing-asp-net-core-project-razor-pages\/\" class=\"more-link\">Continue reading<span class=\"screen-reader-text\"> &#8220;Developing ASP.NET Core Project With VS Code &#8211; Razor Pages&#8221;<\/span><\/a><\/p>\n","protected":false},"author":1,"featured_media":0,"comment_status":"open","ping_status":"open","sticky":false,"template":"","format":"standard","meta":{"footnotes":""},"categories":[92,80,89],"tags":[],"class_list":["post-4146","post","type-post","status-publish","format-standard","hentry","category-asp-net","category-c-3","category-dotnet"],"_links":{"self":[{"href":"https:\/\/myprojects.advchaweb.com\/index.php\/wp-json\/wp\/v2\/posts\/4146","targetHints":{"allow":["GET"]}}],"collection":[{"href":"https:\/\/myprojects.advchaweb.com\/index.php\/wp-json\/wp\/v2\/posts"}],"about":[{"href":"https:\/\/myprojects.advchaweb.com\/index.php\/wp-json\/wp\/v2\/types\/post"}],"author":[{"embeddable":true,"href":"https:\/\/myprojects.advchaweb.com\/index.php\/wp-json\/wp\/v2\/users\/1"}],"replies":[{"embeddable":true,"href":"https:\/\/myprojects.advchaweb.com\/index.php\/wp-json\/wp\/v2\/comments?post=4146"}],"version-history":[{"count":8,"href":"https:\/\/myprojects.advchaweb.com\/index.php\/wp-json\/wp\/v2\/posts\/4146\/revisions"}],"predecessor-version":[{"id":4154,"href":"https:\/\/myprojects.advchaweb.com\/index.php\/wp-json\/wp\/v2\/posts\/4146\/revisions\/4154"}],"wp:attachment":[{"href":"https:\/\/myprojects.advchaweb.com\/index.php\/wp-json\/wp\/v2\/media?parent=4146"}],"wp:term":[{"taxonomy":"category","embeddable":true,"href":"https:\/\/myprojects.advchaweb.com\/index.php\/wp-json\/wp\/v2\/categories?post=4146"},{"taxonomy":"post_tag","embeddable":true,"href":"https:\/\/myprojects.advchaweb.com\/index.php\/wp-json\/wp\/v2\/tags?post=4146"}],"curies":[{"name":"wp","href":"https:\/\/api.w.org\/{rel}","templated":true}]}}