5 Tips to Become a Better Programmer

8 Best Rules for Good Programming Style

ALSO READ: 5 Tips to Become a Better Programmer

Proper programming style significantly reduces maintenance
costs and increases the lifetime and functionality of software. Most software
disasters are rooted in poor style of programming. In this article I am listing
out the 8 best rules that lead to a better programming style.


Good code is written to be easily understood by colleagues.
It is properly and consistently formatted and uses clear, meaningful names for
functions and variables. Concise and accurate comments describe a natural
decomposition of the software’s functionality into simple and specific
functions. Any tricky sections are clearly noted. It should be easy to see why
the program will work and reason that it should work in all conceivable cases.


Code should be written so that it is straightforward for
another programmer to fix bugs or make changes to its functionality later.
Function should be general and assume as little as possible about preconditions.
All important values should be marked as constants which can be easily changed.
Code should be robust to handle any possible input and produce a reasonable
result without crashing. Clear messages should be output for input which is not


Comments are the first step towards making computer program
human readable. Comments should explain clearly everything about a program
which is not obvious to a peer programmer. The volume of comments written is
meaningless, quality is all that counts.Block comments are written using /* comments */ style. They should go at the top of every source
file and generally include your name, the date your code was written and
overall description of the purpose of that program. Block comments should also
precede most functions with a description of the function’s purpose; these can
be omitted for very short, obvious functions only.Inline comments are written as //comments, they should go near important lines of code within
functions or with variables when they are initialized.


Names given to classes, variables, and functions should be
unambiguous and descriptive. Other guidelines for naming are:

  • Capitalization is used to separate multi-word names:
  • The first letter of a class name is always capitalized:
  • The first letter of a function or variable name is always in
    lowercase: setFilled().
  • The names x and y should only be used to describe
  • The names i, j, and k should only be used as variables in
    for loops.
  • Other one-letter names should be avoided: area = base *
    height instead of a = b * h.
  • Names of constants are capitalized, with underscores to
    separate words: BRICK_COLOR.
  • Use abbreviations with caution. max instead of maximum is
    fine, but xprd instead of crossProduct is a problem.


Indentation is used to clearly mark control flow in a
program. Within any bracketed block, all code is indented in one tab. This
includes the class body itself. Each additional for, while, if, or switch
structure introduces a new block which is indented, even if brackets are
omitted for one line statements. For if statements, any corresponding else
statements should line up

White Space

White space is meaningless to compilers, but should be used
consistently to improve readability. Typically three blank lines are left in
between functions. Individual blank lines are used within functions to separate
key sections. Use of spaces varies as well, but inserting one space usually
make expression more readable; next = 7 *
(prev – 1)
 is clear than next=7*(prev-1).

Function Usage

Function should be short and accomplish a clear, specific
task. As much as possible they should be considered “black boxes” which do not
depend on anything except their parameters and can be handle any possible input
gracefully. A common rule of thumb is the “Ten Line Rule”, usually function
longer than ten lines are trying to do too much and should be simplified.Another important aspect of functions is that any repeated
segments of code should be made into a separate function. This will shorten
your program and improve readability.


A final, overlooked aspect of good programming style is how
our program output results and information to users. Part of writing
professional looking programs is providing clear instructions and results to
the users of our programs. This means proper English with no spelling error conditions.
One must always assume that writing programs to be used by somebody with no
understanding of computer programming whatsoever.If you liked the article then please share it!

Call of Duty Mobile stuck on loading screen: COD Mobile not working and update latest

Call of Duty Mobile is reportedly stuck on the loading screen for gamers who have downloaded the new app today.

Reports are coming in of problems playing Call of Duty Mobile on Android and iOS.

Initial issues included Android users being unable to download the game, the same problem not hitting iOS gamers.

But now it appears that a new problem has hit the massive launch of the new Call of Duty game.

According to fans trying to log in and play, they get stuck on the Call of Duty Mobile Loading Screen.

It’s unclear what might be causing issues tonight or how long they might last.

It would be fair to say that being a popular new Call of Duty game, there could be a lot of server strain going on.

No technical advice has been shared on the COD Mobile platforms yet, so hopefully, issues won’t last a long time.

One user reports: “Sometimes it lets you log in other times it gets stuck. Sometimes have to reload 30 times to get it to login. Definitely has to be servers. If you get logged in just don’t log out.

Another adds: “Mine says preparing update and keeps repeating that; chill out guys this happens. jJust wait a few hours and try again.”

Call of Duty Mobile launched earlier today so it makes sense that there could be some issues over the next 48hrs.

A mass increase in players logging on during evening time in Europe could be enough to cause login problems for fans.

It’s expected that more information will be shared by the COD Mobile team if these issues continue tonight.

Here’s some advice on if the game crashes from the Activision FAQ site:

If you experience app crashes or freezes, or the app won’t open when you try to launch it, try the steps below. Be sure to try the app after attempting each step to see if it solves your issue.

1. Restart your device

  • Press and hold the power button for a few seconds.
  • Tap Power off or Restart on your screen. If these options aren’t available, press and hold the power button until your device restarts.

2. Update the app

  • Open your device’s Play Store app.
  • Tap ☰ at the top of the screen and select My apps & games.
  • Find the Call of Duty: Mobile app and tap the Update button if available.

3. Update your device

  • Open the Settings app on your device.
  • Depending on your device, open System update or Software update.
  • Check your update status and install any system updates available.

4. Clear the app’s cache

  • Open the Settings app on your device.
  • Go to your apps. This may be called Apps, Apps & notifications, App Manager, or Manage apps depending on your device.
  • Tap Call of Duty: Mobile.
  • Tap Storage.
  • Tap Clear Cache.

“Call of Duty: Mobile requires a network connection to play. If you’re having trouble connecting to a game, or you’re experiencing lag while playing, be sure to check your network connection.

“A strong Wi-Fi connection is recommended when playing Call of Duty: Mobile. If you’re having trouble on a Wi-Fi connection, try restarting the wireless router if you have access to it.”

5 Tips to Become a Better Programmer

In this article I am sharing the 5 best tips that will really help you to increase your programming skills and become a better programmer.

ALSO READ: 8 Best Rules for Good Programming Style

1. Know Basics

You should have a good understanding of basics of the programming language in which you are working or learning. If your basic concepts are strong then you can solve complex problems by breaking it into smaller problems. Your code should be neat and well structured, so that if you start working with the code after few months then you can easily know where you left off.

2. Practice a Lot

We all know the fact that “practice makes a man perfect”. For improving your skills you have to practice thousands of hours. There are plenty of ways for practicing, like you can solve problems from good programming books or find online programming contests. There are many awesome websites like codechef.comtopcoder.com, etc where you can practice.

3. Be Amenable to Change

Technology is changing very rapidly so you have to aware of such changes. You should make sure that the projects or technologies on which you are working are not outdated. For becoming a better programmer you should always engage yourself in learning new things.

4. Read a Lot

The more you read, the more you learn. Read good programming books, articles, documentations. The best way for reading and learning programming is to join various programming forums and contests.

5. Help Others

Join great forums like stackoverflow.com where you can help other programmers by answering there questions. By helping others you can find answers of your own questions. You can also ask questions in the forums and get your problems solved; this will help you to become better programmer. These were few tips that will surely help you in becoming a better programmer. If you have any other tips then please mention it in the comment section.

Image Source: https://img2.thejournal.ie/inline/4496572/original/?width=630&version=4496572

How to play Call Of Duty: Mobile on PC

Call of Duty: Mobile launched a couple of days ago, and while a lot of people seem to be into it, not everyone has a smartphone capable of playing graphics-heavy games. If you’re one of those people who own a device that can’t game but still want to play COD: Mobile with your friends, then this guide is for you! Tencent, the co-developer of the game released an official PC emulator for COD: Mobile. Check it out!

Step 1

First, you’d want to download the emulator itself. You can find it here. Install the file once it’s finished downloading.

Step 2

From there, find and install COD: Mobile on the Game Center tab.

Step 3

If you initially logged in via Facebook and want to keep your progress, then you’re going to need to download the Facebook Lite app and login there as well. Otherwise, you won’t be able to login to your COD: Mobile account. You can find Facebook Lite in the Game Center as well just search for “Facebook.”.

Step 4

Before running the game, open up the settings on GameLoop. You can find it in the three lines icon on the upper right side of the GameLoop app.

From there go to the Engine tab. Depending on the specs of your PC, adjust these settings. The important thing to take note is the Memory – which is the RAM your “phone” or the emulator has, and Processor (make sure you set this below what your has). If you have multiple Playback and Recording devices, then make sure you set the ones your currently using. For the first five rendering options, I just left it as is.

Step 5

Now you can finally start the game! Head over to the main menu, then go to the My Games tab and hit play.

From here you should see Call of Duty. Hit play and a separate window for the game should pop up. Once you reach this screen, log in using your preferred method; I only tested with FaceBook because that’s where my account is linked, but others should work fine too. The controls are all on the right side so learning them shouldn’t be much of a challenge. One thing is that the left Ctrl key is used to free up the mouse cursor which is useful for the BR mode when looting. But, if you’re a long-time PC FPS gamer, then you know that the left Ctrl key is typically for ducking. Just keep that in mind because I’ve died quite a few times for hitting the Ctrl key and then not being able to aim.

Step 6

The only thing left to do is start playing the game! See you guys out there!

15 Most Common Bad Programming Practices

Here are some most common bad programming practices that every programmer should avoid to become a better programmer.

ALSO READ: 5 Tips to Become a Better Programmer

1. Giving up too soon

Most of the programmers give up when they are very close to solution. So never lose hope and keep trying, you will definitely find a solution.

2. Acting defensively when someone critiques your code

Be calm when someone criticizes your code. Just listen carefully to them; maybe it will help you to improve your code quality.

3. Refusing to ask for help

Don’t be ashamed of asking help from other programmers. Don’t feel that others will think you even don’t know such a small thing. Just go ahead and ask for help. There are several programming forums like stackoverflow where many experienced programmers are active who would definitely help you.

4. Passing blame to others

A good developer is one who takes ownership and responsibility for the code he/she write.

5. Ignoring the opinions of other developers

Pair programming with other experienced developer is one of the best ways to learn and grow as a developer. You can take help of other programmers and senior developers to learn efficient ways of solving a problem that you have solved yourself.

6. Not knowing how to optimize code

Finding solution of a problem should not be your only concern. You should optimize your code in terms of time and space complexity.

7. Acting like a boss, not a leader

If you are a senior developer then you should know how to manage developers in your team. You should act like a leader who can properly lead his/her team.

8. Using the wrong tool for the job

You should be aware of which tool is best for the job. Stop making decisions based on “it’s what I know”. You need to be open to using different technologies, languages, and frameworks.

9. Refusing to research coding questions

Internet is one of the most powerful tools for programmers. You should be really smart to search solution for a problem on sites like google, stackoverflow, etc.

10. Refusing to learn from mistakes

We are humans, we make mistakes. Making mistake is not a bad thing, but refusing to learn from them is bad thing. Find the ultimate cause for the mistake and keep it in mind so that you will not repeat it in future.

11. Separating yourself from the developer community

You should be really active in developers and programmers community. This will help you to have knowledge about latest technologies and trends in the market.

12. Not giving back to the community

You should be always ready for helping other programmers. You can help others by various platforms like stackoverflow, quora, etc. or by writing articles on others or your own blog.


See how I am helping other programmers by this blog. 

13. Struggling for hours to solve something, solving it, and not documenting it

You may get some strange problem whose solution is not there on internet. You spent several hours and found the solution. Now it’s your duty to share the solution on internet so that others will not struggle that much.

14. Bad naming conventions

Use meaningful name for variables, functions, classes, etc. For example, using characters like x, y, z, etc for the variable name instead of something like length, userInput.

15. Writing too many or not enough comments in code

Comments are essential notes to developers. It increases the readability of code. You should properly write comments so that it will help you as well as other programmers to understand the code in future.

If you know some other bad programming habits then please mention in comment. I will love to add them in this article.

Source: https://www.quora.com/What-are-some-bad-programming-practices-every-programmer-needs-to-be-aware-of-in-order-to-avoid-them

5 Facile Yet Incredibly Valuable Ways to Enhance ASP.NET Developer’s Efficiency

The ASP.Net Development has arguably redefined and restructured the ambit of web application development. The new age capabilities of the platform created by Microsoft has features abound of developers to let them think out of the box and create something that paves way for innovation. Creating exclusive application become a prospect rather too realistic and as more number of developers and development companies lean towards ASP.NET, we are sure to witness better and faster web apps.

The framework is also continuously changing and it is being made sure that there are regular upgrades. For an enterprise providing the ASP.NET development services to a client – locally or offshore – it is imperative to keep glued to those changes and let them not surprise them and the clients. To upgrade themselves to the changes, developers need to rise up to the occasion and raise their skill levels and optimize the way they work. There are ways to do so, and those ways are met with certain challenges as well. But they also produce favorable results for businesses. So, here is how you can proceed to hone your results as a developer:

Also Read: http://blogs.magistechnologiesinc.com/5-things-you-must-consider-before-using-asp-net-development/(opens in a new tab)

Make Handling the Requests an Asynchronous Exercise

The customary practice in ASP.Net Development is managing the incoming request synchronously. While this kind of process has its set of benefits, you cannot set priorities with this practice, which leads to mismanagement of time. As the requests are placed in a queue, there is a method to how they are handled. So far, so good, but the lack of prioritization only works the other way for you – the wrong way that is. By using asynchronous pages, you can reduce the total request handling time and let more important applications to run first. 

Use the Browser’s Tools and Extensions

The browsers like Google Chrome and Mozilla Firefox comes with their own set of tools to help developers spend less time in writing darn-out codes and plug their applications with incredible features. The oversight leaded to ignoring these tools will only lead to increased time in developing apps and probably lesser efficiency as well. Look for the tools that are relevant to the app and leverage them in the best way you can. 

Pool the connections to Free up Some Resources

The way applications are connected to the database eats up a lot of resources, which can otherwise be saved by the more optimized practice of connecting pooling. It also helps the TCP connections, though keeping an eye towards
discrepancies like connection leaks becomes more imperative. 

Do not Keep Debuggers Running at All Times

While ASP.NET works in a great way to make sure the errors do not creep in and go unnoticed through the use of various debuggers and tracers to let you know, they also have an impact over the application development speed metrics. If you keep them on, the debuggers will render the whole process slow and bring a marked difference in the way applications are being executed. This further impacts the performance – a not too desirable prospect by any stretch. As and when you need it, you can switch on the debuggers to locate and correct the errors to make sure they don’t surface at run-time. 

Make the Most of Cache Class

Developers, both beginners and experts, often undermine the importance of the cache class. In fact, they ignore the benefits that the overall caching mechanism can provide them with. This mechanism is highly important for making a backup of resources while classifying their validity. The cache class makes this process be carried out with ease. As and when an object is not allowed to cache, the callbacks are summoned. With a nod to the growing evolvement of ASP.NET, developers feel the heat to stay abreast to the latest and most resourceful practices. And if they happen to be a part of a large scale ASP.NET development company, there is an escalated urgency.

5 Things You Must Consider Before Using ASP.NET Development

Today’s contemporary web needs expect you to opt for a programming framework that comes loaded with remarkable benefits. Before choosing a particular framework, you must gauge it in terms of ease-of-use and scalability. Amongst the wide range of programming frameworks available in the web market, ASP.NET has been successful in making it to the list of leading web development frameworks used by web developers across the globe. If you too are about to leverage ASP.NET features for building remarkable web solutions then this is a post you can’t afford to miss. Here, I’ve covered five vital things that you must consider before using ASP.NET as your web development tool.

1. High-grade scalability

For being able to make the most of a web development framework, you must ensure that the same is equipped with high-end scalability options. The more scalable the framework is, the better it would be for you (as a developer) to manage the events and sessions across multiple servers used during web development.

If your web programming framework comes with top-level scalability, you can stop worrying about scaling your web application in accordance to forthcoming advancements in the field of technology. ASP.NET features such as pipeline optimization and process configuration aid you in addressing the varying requirements as your project scales from one stage to another.  

2. An efficient web server

The prime reason behind the increased use of ASP.NET is its excellent web server efficiency. Backed by a brilliant web server, ASP.NET enables you to deal with different web development scenarios in addition to offering you the flexibility of monitoring web pages, modules and specific components. To sum it up, with ASP.NET, you need not stress about the speed of the web server because the framework handles the dedicated memory which is required for building web applications and further protecting the application from a wide array of irregularities and security infringements that might occur during the development process. 

3. Commendable speed

Speed is something that can render more power and authority to the web developers. If you are going with ASP.NET, you can expect quick and prompt arrangement of controls and facilities. Equipped with tables, easy-to-handle grids and wizards, ASP.NET offer you a suite of navigation, allowing you to execute web development projects smoothly. Eliminating the need for configuring a web server, ASP.NET permits you to get started with the app coding process rightaway.

Since ASP.NET runs on its own web server, you need not worry about configuring a new server on your system. The framework automatically spins a web server for your use. This is indeed a feature unavailable in a variety of other web app programming frameworks.

4. Lesser coding

Unlike a wide collection of web app development frameworks, ASP.NET comes with brilliant functional capabilities, thereby eliminating the need for any lengthy and complex coding. Features such as:WYSIWYG editing, drag-and-drop server controls and multi-lingual support make ASP.NET a framework worth working with. These features make ASP.NET a viable option for both professionals as well as the beginners who’ve just started using the framework for developing out-of-the-box web applications.

5. Trustworthy and consistent

With authentication and data validation serving as two strong assets of ASP.NET, it won’t be wrong to call it as one of the most reliable web development systems. Rich in streamlined components, ASP.NET allows a web program to automatically detect and recover from bugs, followed by acting in the right way. Issues such as crash protection, dead locks and memory leaks are being addressed well by ASP.NET.

As a web developer, you’ll no longer have to worry about system exceptions and all the scrubbing incoming data during web app development. ASP.NET is already designed to handle all this and much more for you. All you need to do is delve into some easy coding and you’re done with building a perfect web solution.

Wrapping it all up

The aforementioned pointers are just the tip of an iceberg. There’s a lot more to explore with the ASP.NET programming framework. If you’re looking forward to develop rich and expensive web applications then ASP.NET is the platform you can choose without giving a second thought. Looking at the ever-growing demands of today’s clients, ASP.NET is the tool that will help you meeting every type of web app development requirement.

Create Dynamic Menu in ASP.NET MVC – A Complete How to Guide

A menu plays a significant role in lending an amazing UX by making an application easily navigable. It can be used to make accessibility to a particular section a breeze.If you want to ensure a surefire application, it is essential that elements of your application must be accessed with ease. It must appear intuitive and intriguing, so that users can execute them with a flair. You may create multiple modules within a project and depending upon the user’s permissions, an appropriate menu can be implemented dynamically via ASP.NET.

ASP.NET is an open source server side framework that augments web app development with great efficiency and precision. It is the core of the popular Content Management Systems (CRM), eCommerce, and so forth that deliver utile features.

Here is a comprehensive guide that offers a complete tutorial for creating a user-friendly dynamic menu via ASP.NET MVC. The process is extremely simple with only 5 easy steps at a glance.

Let’s distill the process and explore how dynamic menus can be created efficiently.

Create Dynamic Menu in ASP.NET MVC

Step 1: Create a database table

To create dynamic menus in ASP.NET MVC, the very first step is to generate a database table that can hold all the menu items in a designed hierarchy (if any). The database table can be created with a simple query as mentioned below.

Create Table Menus(ID int Primary Key Identity(1,1), ParentID int foreign key References Menus(ID), Title varchar(50), Description varchar(250))

This query will create a table Menus that will hold four values. These values are:

ID: is the primary key and auto generated
Parent ID: is the foreign key
Title: Name of the field
Description: is the information that you want to display when a user hovers over the menu.

With this, a desired table will be created in the database.

Step 2: Insert values into the table

A simple insert query can be used for adding the data into the table. Now, there are two possibilities, that is, your menu may possess multiple parent items that further possess child items or there may be parent items only. So, you must insert the values as per your app requirements.

Query to insert values into the table Menus.

Insert Into Menus(null, ‘Item One’, ‘Desc’) // First Parent Item
Insert Into Menus(null, ‘Item Two, ‘Desc’) // Second Parent Item
Insert Into Menus(null, ‘Item Three’, ‘Desc’) // Third Parent Item
Insert Into Menus(1, ‘Item Sub One’, ‘Desc’) // Child of First Parent Item
Insert Into Menus(2, ‘Item Sub Two’, ‘Desc’) // Child of Second Parent Item
Insert Into Menus(3 ‘Item Sub Three’, ‘Desc’) // Child of Third Parent Item

By implementing the above mentioned queries, your Menus table will contain three items in the Menu and each item will further have a child item.

Step 3: Fetch the data from the table

Now, the next step is to fetch the menu items from the table Menus that was created in the step 1, and return a list of all the items.

For this, a GetMenus() function is created in MyMenu class. In this function, there is a loop that will help fetch the items of the Menu and return them via a list. The lines of code for the same is as follows.

Code Snippet for model:

public static class MyMenu
   /// <summary>
   /// Get List of All Menu Items from Database
   /// </summary>      
   /// <returns>Returns List<Menus> object</returns>
   public static List<Menus> GetMenus()
       using(var context = new ProjectEntities())
            return context.Menu.ToList();

Step 4: Display the created menu on the screen

Now, when the Menu items has been fetched from the database, it is the time to represent it in the view.

Code Snippet for View:

    List<Menus> myMenu = MyMenu.GetMenus();
    var plist = myMenu.Where(m => m.ParentID == null).ToList(); // This will list main menu items on which we’ll apply loop to display them.
    if (plist != null && plist.Count > 0)
        <ul class=”nav”>
        @foreach (var pitem in plist)
                <a href=”{URL-Required} title=”@Description”>@pitem.Title</a>
                    var clist = myMenu.Where(m => m.ParentID == pitem.ID).ToList();
                    if (clist != null && clist.Count > 0)
                            @foreach (var citem in clist)
    <li><a href=”{URL-Required}”title=”@Description”>@citem.Title</a></li>

Here, ui and li HTML tags are used in the loop. This will help display the created menu in the view. Now, move to the next step.

Step 5: Beautify the menu to make it appear captivating

To ensure an enticing and easily readable menu, it is essential to make it appear visually appealing and intriguing. You may use the CSS appropriately to enhance the look and feel of the menu in a desired fashion. Here, I have incorporated the following chunk of code in the CSS file to boost the navigation ease and ensure an attractive Menu.

Code Snippet CSS:

ul, ol, li {list-style: outside none none;}
.nav {float: left;padding: 0;background-color: #5eab1f;}
.nav li {display: inline-block;position: relative;vertical-align: middle;}
.nav li:hover, .nav li.active {background-color: #4c9312;}
.nav li a {color: #fff;float: left;font-size: 15px;padding: 16px 14px; text-decoration: none;}
.nav li ul {background-color: #fff;border-radius: 0 0 5px 5px;box-shadow: 0 2px 3px #000;display: none;min-width: 200px;padding: 20px 0;position: absolute;top: 48px;z-index: 9999;}
.nav li ul:before {border-bottom: 8px solid #fff;border-left: 8px solid transparent;border-right: 8px solid transparent;content: “”;left: 28%;position: absolute;top: -8px;}
.nav ul li {float: left;width: 100%;}
.nav ul li a {color: #333;float: left;font-size: 15px;padding: 10px 5%;width: 90%;}
.nav li:hover, .nav li.active {background-color: #4c9312;}

This CSS has been created considering a few requirements, you may develop it in a desired fashion to bring substantial changes in the visual appearance. Therefore, you may streamline the CSS as per your UX and design needs.

Wrapping Up

By following this absolute guide, you can efficiently create beautiful dynamic menus via the ASP.NET MVC. It is advisable to thoroughly go through each step and design desirable menu while ensuring utmost navigation ease.

Create ASP.NET MVC 5 Application Using Model First Approach [Detailed Guide]


Many ASP.NET developer find writing and managing code for data access a monotonous job. But there is some good news. Microsoft provides an O/RM framework called Entity Framework that helps to automatically handle all your database related activities for your app, eliminating the need to write data-access plumbing code. In essence, Entity Framework helps in making your ASP.NET app easier to maintain. The Entity Framework provides three approaches that helps to connect ASP.NET application to database. These three approaches are:

  • Model First
  • Database First
  • Code First 

In this post we will talk about Entity Framework model first approach, and to help you better understand this approach we will also create a sample ASP.NET MVC application using model first approach.

Also Read: Create Dynamic Menu in ASP.NET MVC – A Complete How to Guide

But before that, let’s first an overview of the latest 6.1 version of Entity Framework. 

A Brief Introduction on Entity Framework 6 

Entity Framework 6 (EF6) has introduced many new interesting features for its approaches. The latest EF 6 version works well with projects using the .NET Framework 4 (and later) and Visual Studio 2010 or later. Let us take a some of the important features of Entity Framework 6:

  • Dependency Resolution 
  • Connection Resiliency
  • Multiple Contexts per Database
  • Code Based Configuration
  • Code First Mapping to Insert/Update/Delete Stored Procedures and many more.

In our example, we will be working on Visual Studio 2013.

Let’s Get Started

In order to create MVC 5 application with help of the Model First Approach, we’ll have to go through each one of the following sections:

  • Creating Web Application
  • Adding Entity Data Model
  • Working with Entity Data Model Designer
  • Working with Controller and Views
  • do CRUD Operations
  • Working with Database 

Creating Web Application

Here, we will take an example to learn the process of creating an ASP.NET web application with help of the MVC Project Template. Follow the below mentioned steps to proceed:

Step 1: Open Visual Studio 2013 and then click on New Project.

Step 2: Click on the Web tab from the left side of the window, and then select the ASP.NET web application and assign name to the application as “ModelFirstApproach”.

Step 3: As shown in the screen shot below, you will have to choose the MVC Project Template and click on the OK button.

Visual Studio will create the MVC application automatically and add several files and folders to your project. You can check out all those files and folders from the Solution Explorer.

Adding Entity Data Model

In this section, as the name implies, we will be adding an Entity Data Model (i.e. the ADO.NET) to the application. For doing so, we will first create an empty model using the below given procedure: 

Step 1: Right-click on the Models folder in the Solution Explorer, and then click on its corresponding Add option. From the Add pane click on ADO.NET Entity Data Model.

Step 2: In this step, you will need to define the model name and click on OK. In our example, we have specified the model name as “ModelFirstModel”.

Step 3: Next from the Entity Data Model Wizard, click on the Empty Model option and hit the “Finish” button.

Following the above step, you will be able to see the Entity Data Model Designer (i.e. ModelFirstModel.edmx).

Working with Entity Data Model Designer

Here, we’ll add the entity in newly created Entity Data Model Designer using two sections, as listed below:

1. Adding Entity Model

In this section, we will create the entity model by following the below given procedure.

Step 1: Right-click on the Entity Data Model Designer and click on Add New>>Entity. This will help to add new entity as follows:

Step 2: Now in the “Add Entity” wizard, specify the name of your entity.

Note: We have specified Books as our entity name, however, you can change it according to your own requirement. 

Step 3: Once you’ve completed creating the entity, you’ll have to add a scalar property to it. For doing so, right-click on the Entity click on Add New>>Scalar property.

Now we’ll change the property name. 

Step 4: You can choose to add even more scalar properties to the entity i.e. Books.

Note: You can create more entity models as per your requirement in the Data Model Designer. 

2. Generate Database from Model

After generating an entity model, it’s time to generate the database from the model. For this purpose, simply follow the below mentioned steps: 

Step 1: Right-click on the Data Model Designer space and click on the “Generate Database from Model” option.

Step 2: When the Generate Database Wizard opens, click on “New Connection” for establishing a connection with the database.

Step 3: When the Connection Properties wizard opens, you will need to assign a name to the server and the database.

Next, click on “Test Connection” to ensure whether the connection has been established or not. 

Step 4: The connection with the database will be created, as you can see in the Generate Database Wizard. And then, click on the Next button.

Step 5: In this step, the database summary and script will be generated. After that, click on the “Finish” button.

Step 6: Next, right-click on the script that is being generated and click on Execute. 

Clicking on execute will create the database that you can see in the Server Explorer as shown below:

Working with Controller and Views

Till now, we have worked with the database. So far we have the done the work with the database. And now we’ll be working with the controller as well as views in MVC 5. First off, we’ll use the Entity Framework to add the MVC5 Controller using the following procedure:

Step 1: We’ll have to build the solution, in order to locate the model class in the Models folder. Books class is generated in the models folder (i.e. ModelFirstModel.edmx). Simply edit the code with the highlighted code as shown in the screenshot below:

Step 2: In the Solution Explorer pane, right-click on the Controller and click on Add>>New Scaffolded Item.

Step 3: Now the Add Scaffold wizard will open. From this wizard, select the option “MVC 5 Controller with views, using the Entity Framework”.

Step 4: Now in the Add Controller Wizard, we’ll be specifying the following fields:

  • Controller name 
  • Model class 
  • Data Context class 

And then, click on Add.

After clicking on the Add button, the BooksController class is generated inside the Controllers folder. In addition, the Books folder is generated within the Views folder as highlighted in the screen shot below:

Do CRUD (CReate-Update-Delete) Operations

Here we’ll be performing CRUD operations: Create, Read, Update and Delete using the following procedure:

1. In the very beginning, we will be creating an “Action Link” to our View. For this purpose, we will go to the Views>>Shared>>_Layout.cshtml file and will edit the code with the following code:

<meta charset="utf-8"/>
<meta name="viewport" content="width=device-width,initial-scale=1.0">
<title>@ViewBag.Title-Books App</title>
<div class="navbar navbar-inverse navbar-fixed-top">
<div class="container">
<div class="navbar-header">
<buttontype="button" class="navbar-toggle" data-toggle="collapse" data-target=".navbar-collapse">
<span class="icon-bar"></span>
<span class="icon-bar"></span>
<span class="icon-bar"></span>
@Html.ActionLink("Best Books", "Index", "Home", null, new{@class="navbar-brand"})
<div class="navbar-collapse collapse"> 
<ul class="nav navbar-nav"> 
<li>@Html.ActionLink("Home", "Index", "Home")</li> 
<li>@Html.ActionLink("About", "About", ”Home")</li> 
<li>@Html.ActionLink("Contact", "Contact", "Home")</li> 
<li>@Html.ActionLink("Books", "Index", "Book")</li>


<div class="container body-content">
<p>©@DateTime.Now.Year -My Books Application</p>
@RenderSection("scripts", required: false)

In this code, we’ve created an action link. In addition, we have edited the app name and its title. 

2. Now we will be working with the CRUD operations:

2.1 Create:
In this particular section we will be working on Create operation.

Step 1: First off, we’ll run the application we have created. In our application home page we’ll click on Books.

Step 2: After clicking on Books from the navigation tab, a window will open (as shown below). In this window, we’ll click on the “Create New” link for creating the record for our Books application.

Step 3: In the next window, fill all the fields (as shown below) and click on Create.

You can add as many records as you want using the same procedure. Once your record gets created, you can perform two operations on it:

2.2 Read:
You can read the corresponding records, when you click on the Books link. 

2.3 Update:
You can update the corresponding record by following the below mentioned steps:

Step 1: Open your record you want to edit, and click on the Edit link. 

Step 2: Now edit the record and hit the “Save” button.

3. Delete:
You can even delete the record you’ve created, by clicking on the Delete link. 

Working with Database

Now all the tables and records will be updated in the database. In order to view them using the Server Explorer, follow these steps: 

Step 1: In the Server Explorer, click on the Model folder. Next, right-click on the Tables folder and click on Books>> Show Table Data.

Step 2: Now, all the records will be visible on the screen.

That’s it for now! Hope reading this tutorial will help you learn how you can create an ASP.NET MVC 5 application using EF model first approach. 

4 Free ASP.NET Hosting Websites

Here you will know about some best and free asp.net hosting websites.

Are you a student or developer? Do you have ASP.NET website? Want to test your ASP.NET project online? Want to host ASP.Net and SQL databases for free? Then this article might helpful for you. We will see some free Windows Server OS based web hosting services. Basically applications like ASP.NET, MSSQL, MS Access, etc requires windows server OS to run the websites. This is the main difference between Windows and Linux based hosting sites. So let’s start.

4 Free ASP.NET Hosting Websites


Somme.com provides free windows ASP.Net hosting on Windows 2012 or Windows 2003. The registration is absolutely free and does not require credit card information to complete registration. Somee.com provides only 1 website to host free of cost. They also provides FTP to transfer your web files by using of free ftp clients.


  • Storage capacity: 150MB
  • Transfer rate: 5GB/Month
  • Free Subsomain
  • IIS 8.0/7.5/6.0
  • ASP.Net 4.5/ 4.0/3.5/2.0/ 1.1
  • AJAX 3.5/1.0
  • MVC 1.0/2.0/3.0/4.0
  • Silverlight
  • Databases: MS Access 2003, 2007/MS SQL Express 2012, 2008R2
  • MS SQL databases size: 15MB
  • MS SQL log size: 20MB
  • Backup storage size: 40MB


  • Some what low storage capability.
  • Forced advertising (You will see advertising on your hosted website.)
  • Low database storage size.


Mywindowshosting.com web hosting service for 60 Days free trail for your ASP.Net website. After free 60 days trail period you have buy or upgrade to their paid hosting plans. Registration is free and no credit card information is needed for activation. They believes in try it before buy it. You will get free support for your trail period from mywindowshosting.com. You can use this web hosting site for your small web based project for testing.


  • Storage Capacity: 1GB
  • Number of Site/IIS Entry: 1
  • Domain Names Hosted: 1
  • Bandwidth: 10GB
  • 1 FTP Account
  • Windows Sever OS: 2012/2008
  • MS Access Database
  • MS SQL Database: 2012/2008/2005
  • ASP.Net: 4.5/4.0/3.5/2.5
  • Firewall, Anti Virus and Daily Backup
  • 24X7 Technical Support
  • No Advertisements


  • Only 60 Days free trail subscription


AspSpider.com offers web hosting for educational purpose at no cost. You can use their hosting services to create ASP.NET websites and give demonstrations to your manager or client without spending any money. The service is purely for learning and educational purpose and absolutely no commercial sites are allowed except for demo purpose.Registration is fairly simple and no credit card is required.


  • ASP.NET 4.0/3.5/2.0
  • No Advertising
  • MS SQL Server 2008/ 2005 Express Edition
  • MS Access support
  • 100 MB Disk Space
  • 2 GB Monthly Data Transfer


  • Low storage space
  • No ASP.Net 4.5 Support
  • Low monthly transfer rate
  • No FTP support


AspHost4Free.com provides free web hosting service for your ASP.Net and MS Access database. Registration is free and no credit card information is needed. Let’s look at the features and disadvantages.


  • 100MB Disk Space
  • No Advertising for limited time
  • FTP Support
  • Unlimited Bandwidth
  • Technical Support via E-mail
  • MS Access Database
  • Standard ASP Scripts


  • Low Disk Space
  • No MS SQL Database (You have to compromised with MS Access database)
  • Ads will displayed after limited time is over.