In most applications we have a persistence layer, often called the repository layer. In this tutorial we create a PetStoreRepo project to use DynamoDB to store our data. Since our PetStoreRepo will use AWS DynamoDB, we use the LazyStackDynamoDBRepo NuGet package that implements generic Create, Read, Update, Delete and List (CRUDL) operations on the Amazon DynamoDB.
dotnet new classlib -o PetStoreRepo
Windows: dotnet sln add PetStoreRepo\PetStoreRepo.csproj
MacOS/Linux: dotnet sln add PetStoreRepo/PetStoreRepo.csproj
You now have a PetStoreRepo C# Class Lib project in your solution.
<Project Sdk="Microsoft.NET.Sdk">
<PropertyGroup>
<TargetFramework>net6.0</TargetFramework>
<ImplicitUsings>enable</ImplicitUsings>
<Nullable>enable</Nullable>
</PropertyGroup>
<ItemGroup>
<ProjectReference Include="..\..\LazyStack\LazyStackDynamoDBRepo\LazyStackDynamoDBRepo.csproj" />
<ProjectReference Include="..\PetStoreSchema\PetStoreSchema.csproj" />
</ItemGroup>
</Project>
Note the TargetFramework is "net6.0".
dotnet build
The solution compiles successfully.
Note the reference to the LazyStackDynamoDBRepo.csproj residing in the LazyStack repository we cloned in the first step of this tutorial. In a production app you might choose to reference the corresponding NuGet package instead.
In this step we implemented the PetStoreRepo project by: