Creating a data project
To save our blog posts, we will use JSON files stored in a folder and to do so we need to create a new project.
Creating a new project
There are many ways of persisting data, document databases, relational databases, and files to name a few. To remove complexity from the book we will use the simplest way of creating blog posts simply by storing them as JSON in a folder.
The data will be accessible from both our Blazor WebAssembly project and the Blazor Server project, so we want to create a new project (not just put the code in one of the projects we created previously).
We can create a new project from within Visual Studio as well (to be honest, that's how I would do it) but to get to know the .NET CLI, let's do it from the command line instead.
To create a new project, follow these steps:
- Open a PowerShell prompt.
- Navigate to the
MyBlog
folder. - Create a class library (
classlib
) by typing the following command:
dotnet new classlib -o Data
The dotnet...