Build ASP.Net Core Razor Page Application

In this post, I’m going to show how to build Core Web Application with Razor Pages.

Razor Pages is a new aspect of core MVC, Razor pages make a coding page focused approach to develop web applications.


  • Visual Studio.
  • .net Core SDK.

Let’s move to project set up,

Step 01,

  • From the Visual Studio File menu, select New > Project.
  • Create a new ASP.NET Core Web Application. Name the project Store.


Step 02,

  • Select ASP.NET Core 2.1 in the drop-down, and then select Web Application.2
  • Then Visual studio template creates a Razor Project.3
  • After Successfully creates the project you can run it.

Step 03,

Now we are going to Connect with Database using Razor App,

We are going to implement App using Entity Framework DB Approach.

To use EF Core, install the package for the database provider(s) you want to target. This walkthrough uses SQL Server. For a list of available providers see Database Providers.

  • Tools > NuGet Package Manager > Package Manager Console
  • Run Install-Package Microsoft.EntityFrameworkCore.SqlServer

We will be using some Entity Framework Tools to create a model from the database. So we will install the tools package as well:

  • Run Install-Package Microsoft.EntityFrameworkCore.Tools

We will be using some ASP.NET Core Scaffolding tools to create controllers and views later on. So we will install this design package as well:

  • Run Install-Package Microsoft.VisualStudio.Web.CodeGeneration.Design


Create a Database Called “StoreDB” & then Create a table called “Product” with following columns,


Then create the Entity Framework model based on your existing database.

  • Tools –> NuGet Package Manager –> Package Manager Console
  • Run the following command to create a model from the existing database:

Scaffold-DbContext “Data Source=295_LP1\SQLEXPRESS2012;Initial Catalog=StoreDB;User ID=sa;Password=123” Microsoft.EntityFrameworkCore.SqlServer -OutputDir Models



Step 04,

  • In Solution Explorer, right-click on the Pages folder > Add > New Folder.
  • Name the folder Movies

In Solution Explorer, right-click on the Pages/Movies folder > Add > New Scaffolded Item.


Complete the Add Razor Pages using Entity Framework (CRUD) dialog:

  • In the Model class drop down, select Movie (Store.Models).
  • In the Data context class row, select the + (plus) sign and accept the generated name Store.Models.StoreDBContext.
  • In the Data context class drop down, select Store.Models.StoreDBContext
  • Select Add.



To register as a service, open Startup.cs, and add the highlighted lines to the method.

public void ConfigureServices(IServiceCollection services) { services.AddDbContext<StoreDBContext>(options => options.UseSqlServer(Configuration.GetConnectionString(“DefaultConnection”))); services.AddMvc(); }

Open the appsettings.json file and add a connection string as shown in the following code:

“ConnectionStrings”: {
“DefaultConnection”: “Data Source=295_LP1\\SQLEXPRESS2012;Initial Catalog=StoreDB;User ID=sa;Password=123”
“Logging”: {
“LogLevel”: {
“Default”: “Warning”
“AllowedHosts”: “*”


Now run your project,

Then you can do CRUD operations with Razor Web APP.



Build MVC Project with Oracle Data Base using Entity Framework DB first approach

In this article i want to explain how to create MVC Application with Oracle Database using Entity Framework DB first approach.

first you have to install visual studio, i’m going to demonstrate using Visual Studio 2015, because at the moment Oracle  provided Oracle Developer tools for Visual  Studio up to visual studio 2015 version. then you have to install Oracle Data base in your local machine or you can access remote Oracle DB.

you can download Oracle Developer tools using this Link

After successfully installing Visual Studio and Oracle Developer tools (ODT), lets go to steps ,

Step 01

Open Visual Studio and Create Empty MVC Project.

Step 02

Then you have to install Oracle Managed DataAccess and Oracle Managed DataAccess Entity framework packages using Nuget package manager to your Project.

after successfully installing Oracle Packages you can see those packages inside the references.

Step 03

Then you have to connect oracle Connection to Visual Studio Data Connections by Providing Oracle Connection Properties.

Step 04

Then add model to your project, in this process you  have select your connection and Database properties such as Tables , Views etc.

After that it will create Database Context and model entities in side your project.then you will see the Model entity classes inside your project.

Step 05

Then you have to provide password for Web Config connection String, because in Context and Model Generating process it will not provide password for your connection string.


Step 06

Now Almost done, you can call Database and Retrieve Values from Database.

i have create new controller and Access connected database using Context (Entities).



Note : if you get Exception like below while run the application ,

Type is not resolved for member ‘Oracle.ManagedDataAccess.Client’

you have register you oracle Manage data access in Global Assembly Cache (GAC).

Below is the Steps of Register Oracle Managed Data Access in GAC.

Set Path to Oracle Managed Data Access stored in :

C:\Windows\system32>cd E:\ud\packages\Oracle.ManagedDataAccess\

then Run Below command to add GAC

E:\ud\packages\Oracle.ManagedDataAccess\>”C:\Program Files (x86)\Microsoft SDKs\Windows\v8.1A\bin\NETFX 4.5.1 Tools\gacutil.exe” /i Oracle.ManagedDataAccess.dll

if Successfully Added to GAC you will see below messege in CMD,

Microsoft (R) .NET Global Assembly Cache Utility.  Version 4.0.30319.33440
Copyright (c) Microsoft Corporation.  All rights reserved.

Assembly successfully added to the cache