How to setup an ASP.NET MVC 5 with Entity Framework and Membership using Visual Studio Code?

This is my first post for this year, it is a pretty delayed update (ごめんなさい), been busy (忙しい), but I can’t wait to share to you guys one of the coolest feature of the new ASP.NET.  The ability to run ASP.NET on any operating system using Visual Studio Code, how cool is that!  Microsoft totally overhauled the entire product and a paradigm shift is absolutely necessary for old developers like me.  Wow!  so lets get started, shall we!

First download Visual Studio Code (the new IDE) using this link: https://code.visualstudio.com/Download

Since the new IDE is only an editor, you will need to install a package manager.  The package manager that you should install is npm.  npm is a package manager associated with nodejs, so just download nodejs using this link (https://nodejs.org/en/) and install.  Boom!

The next to be installed is the ASP.NET execution environment, the new execution environment is ASP.NET 5/DNX.  The new execution environment can run on any operating system, e.g., Windows, MAC, Linux, etc.  I am using a Windows machine so I’ll be using a command line and sample image below:

@powershell -NoProfile -ExecutionPolicy unrestricted -Command "&{$Branch='dev';iex ((new-object net.webclient).DownloadString('https://raw.githubusercontent.com/aspnet/Home/dev/dnvminstall.ps1'))}"

b5

After the installation make sure you type in the following command:

dnvm upgrade

So now we have our IDE Editor (Visual Studio Code),  Package Manager (npm) and Execution Environment (dnvm).  We are ready to build our first application!

To create your first application just type in the following commands:

npm install -g yo grunt-cli generator-aspnet bower
yo aspnet
cd <NAMEOFYOURAPP>
dnu restore
code

The first command,”npm..”, installs all packages necessary to build your first application.  The second command “yo…” creates your application directory and ASP.NET base code scaffolding.  By the way, choose “Web Application” from the list provided by the second command so that Entity Framework and Membership are included in the scaffolding.

Go inside to your application directory by typing “cd” command, once inside the directory type “dnu…”.   This step enables you to download all the necessary bin packages for your project, e.g., Entity Framework, ASP.NET Core, etc.  via NUGET!  The reason why you need this command is that the scaffolding you just downloaded does not contain any references, this will download those references for you.

The last command is “code”, this will execute and run Visual Studio Code.  And now you will see this:

b1

To test if you can run your application, just press Ctrl+Shift+P, then type dnx: Run Command: See image below: (DO THIS TWICE, to remove the Omnisharp error)

b2

Actually when your doing the dnx: Run Command you are already compiling and executing your application.  And take note of URL http://localhost:<PORT> as shown in the image below.  Open a browser and type that URL.

b3

Now you have a running ASP.NET 5 Application with Entity Framework and Membership!

b4

That’s it!  The next blog will be configuring your data, till then! and if you find this blog helpful, you can make the donation by clicking the Paypal button below.


					
Advertisements
About

Software developer living in the Philippines.

Posted in ASP.NET

Leave a Reply

Fill in your details below or click an icon to log in:

WordPress.com Logo

You are commenting using your WordPress.com account. Log Out / Change )

Twitter picture

You are commenting using your Twitter account. Log Out / Change )

Facebook photo

You are commenting using your Facebook account. Log Out / Change )

Google+ photo

You are commenting using your Google+ account. Log Out / Change )

Connecting to %s

Author

Harold Glenn P. Minerva
Software Developer / Tech Enthusiast
Living in the Philippines

View Harold Glenn Minerva's profile on LinkedIn

Instagram

Software Engineer - Seasonal and Range Trading Software. Magenta Trader is a powerful stock market visualization software that increases your probability of trading success.

Software Architect and Founder - Easyfis.com is a multi-tenant cloud-based Software-as-a-Service (SaaS) business app that caters to micro, small and medium trading businesses.

CTO and Co-Founder - We give your company the leverage by providing innovative software solutions products such as Point-of-Sales (POS), Financial Information System (FMIS), Payroll and DTR (HRIS), and many more.

%d bloggers like this: