Build A New MusicStore Project Using NancyFX And PostgreSQL

In this article, you will begin to build a new MusicStore project, using NancyFX and PostgreSQL.

NancyFX

Nancy is a lightweight, low-ceremony framework for building HTTP based Services on .NET Framework/Core and Mono.

For more information about NancyFx, you can visit GitHub and its official site.

https://github.com/NancyFx/Nancy

http://nancyfx.org/

Preparatory Work

As we all know, there are two parts of MVC MusicStore- one is related to the store and another is related to MemberShip, which is given below.

Before building the project, we should migrate the database from SQL Server Compact Edition database file to PostgreSQL and MvcMusicStore is the only one thing which we require. We can easily generate SQL file from SQL Server Compact. Subsequently, edit and execute this file in pg Admin.

Now, we have to migrate the musicstore's data to the PostgreSQL and we need a new table to store the users. Hence, we create a new table in the database.The script is given below.

The next step which we should do is to configure PostgreSQL, so that we can visit it via the remote way. We edit the file pg_hba.conf, update the line host all all 127.0.0.1/32 md5 to host all all 0.0.0.0/0 md5.

Create Project And Install Packages

Now, we can create a new empty ASP.NET project and install some package from Package Manager console.

Install-Package Nancy -Version 1.4.3

Install-Package Nancy.Hosting.Aspnet -Version 1.4.1

Install-Package Nancy.Viewengines.Razor -Version 1.4.3

Install-Package Nancy.Authentication.Forms -Version 1.4.1

Install-Package Dapper

Install-Package Npgsql -Version 3.1.9

The packages given above are all we need to install in this project. I remove the useless DLL's from the project as well. After this step ,the references may look, as shown below.

Add and Configure Static Content

Add two folders in the project, where one is Content, the other is Scripts and copy the resource from mvcmusicstore and what we need are given below.

For using those static contents, we need to add some configuration in the bootstrapper class.