netcore

“Building a simple Blog Engine using ASP.NET Core”.

The architecture of project was based on the common N-Layers architecture for web development (https://docs.microsoft.com/en-us/dotnet/standard/modern-web-apps-azure-architecture/common-web-application-architectures)

Demo:

Because I deploy to Google Cloud, hence I used MySql provider of entity framework. With the security reasons, I set authorized to access to My SQL instance with trust IP addresses. If you want to run Web project (WebBlog, WebBlog.Api, WebBlog.Auth) as your localhost. Please use SQLite provider.

To use SQLite provider of entity framework

  • Remove MySQL package reference

  • Add SQLite package reference

  • In Startup.cs change UseSqlServer to UseSqlite

  • Update connection string:

      	+ "WebBlogDBConnection": "Data Source=webblog.db"
      	
      	+ "WebBlogIdentityDBConnection": "Data Source=webblogIdentityDB.db"	
    
      	(Database files also was commited in folder ../WebBlog.Database/Data)
    
  • Delete add existing migration and Add the new one for SQLite

INSTRUCTIONS:

1/Please make sure your connection strings in appsettings.json point to a local SQL Server instance.

2/Open a command prompt in the Web folder (~\WebBlog\WebBlog) and execute the following commands:

dotnet restore dotnet ef database update -c WebBlogDbContext -p ../WebBlog.Database/WebBlog.Database.csproj -s WebBlog.csproj dotnet ef database update -c ApplicationDbContext -p ../WebBlog.Database/WebBlog.Database.csproj -s WebBlog.csproj

3/If you need to create migrations, you can use these commands:

-- create migration (from Web folder CLI) dotnet ef migrations add InitialModel --context WebBlogDbContext -p ../WebBlog.Database/WebBlog.Database.csproj -s WebBlog.csproj -o Data/Migrations dotnet ef migrations add InitialIdentityModel --context ApplicationDbContext -p ../WebBlog.Database/WebBlog.Database.csproj -s WebBlog.csproj -o Data/Migrations

4/I built the client SPA with technologies: (React + webpack + typescript).

Open a command promt in the Web SPA folder (~\WebBlog\WebBlog.SPA) and execute the following commands:
	
	npm install 
	npm run-script build
	npm start

(url: http://localhost:5000)