Friday, April 22, 2016

DocumentDB data in Visual Studio with cloud explorer

Recently, During Global Azure Boot camp presentation , One offline question was asked that how we can see and browse the data from DocumentDB. So I thought there will be lots of developers who might have the same question that where I can see data from DocumentDB in visual studio.

Yes you can see your DocumentDB data into visual studio. There is an extension called Cloud explorer from where you can browse all the services of Azure. With Visual Studio community edition its comes inbuilt But If you have not that installed then you can install via following steps.

How to install Cloud explorer in Visual Studio:

Open visual studio and go to Extensions and updates like below.


Once you click on that it open a window loading all the extensions select online and type cloud in the search box and you will able to see cloud explorer like below.


I have Cloud explorer installed in my Visual studio that’s its showing Green tick otherwise it will show download button there and you can download and install it.

You can also download manually from the following link.

For Visual Studio 2015:

For Visual Studio 2013:

How to use Cloud explorer to see data of DocumentDB:

One you are done with installing Cloud explorer, You can load that from View Menu-> Cloud explorer in Visual Studio. It will load like below.


Here I have already given my Azure Credentials If you have not given that it will ask for credentials and then will load this screen.

Here it will show the list of all services available for storage. To see what is there in our DocumentDB account click on DocumentDB Account.  It will show your account name lie below.


One you click on the database name it will show all the collection and record below.


One you select records(JSON documents) and right click. It asks for you to open in the editor like below.


Once you click on open editor, It will ask open that JSON document like below.


So you can see that it's very easy to browse data of DocumentDB in cloud explorer in Visual Studio itself. Hope you like it. Stay tuned for more!.
Wednesday, April 20, 2016

Visual Studio code 1.0 Released

Microsoft has released visual studio code on 1.0 version 14th April 2016. Those who have not used Visual Studio code, Visual studio code a is cross platform open source editor from Microsoft. It supports the variety of languages and you can do almost everything that you can do in an IDE. It also provides support for the debugging few languages.

In blog of Visual Studio Code, Microsoft says
Since our initial launch one year ago, 2 million developers have installed VS Code,” the Visual Studio Code team revealed. “Today, we’re excited to report that more than 500,000 developers actively use VS Code each month.
Image source: Visual Studio code blog.

There is some important milestone that Visual studio code is received like following.
  • Visual studio code is now fully localizable and supports 9 languages
  • Visual studio supports extensions and community has built more than 1000 extensions in such a sort span
  • It now supports syntax highlighting and few more features for more than 100 languages.
  • It got more than 300+ pull request on Github.
It will be interesting to see how Visual Studio Code move ahead. I have used it for many times and I am quite happy with it.

You can find more information about it at the following link.

If you have not used it then I recommend you to download this and try it from the following location.

That’s it. Hope you like it. Stay tuned for more!
Sunday, April 17, 2016

Global Azure Bootcamp 2016 Ahmedabad–Awesome event recap

Yesterday, Ahmedabad User group has organized the Global Azure Bootcamp 2016 event. It was a fun to be there. The event was very well received and attended by the group of people excited about Azure cloud platform.  Thanks for hosting is Ahmedabad User Group.


Event Recap:

In the morning, Event is started around 10:00 am. Mahesh had made all attendees comfortable and given some insights about Azure platform.


After that, It was my time to present some. I have shared my knowledge about DocumentDB with my presentation about Introduction to DocumentDB.


There well lots of interest in the audience and we had lots of conversation about it. Here is the presentation link for the same.

Here was the agenda for my presentation.

  • What is document databases?
  • What is DocumentDB?
  • Why we should use DocumentDB?
  • How we can use DocumentDB?
You can also find demo code for the presentation at the following location.

Due to the huge interest in people, We promise them to have some advanced level sessions about DocumentDB in forthcoming months.

After that Jagdish has taken over the stage and had presented about Azure mobile services. He presented how we can leverage Azure mobile services with Windows Phone Application and some other cool insights for Azure mobiles services.


Then we had lunch and we had some great interaction and conversation about cloud technologies during lunch.


After lunch, there was post lunch session. It was time for Sanket Shah to rock the stage. He has presented about Architecting Modern solution on Azure.  He had some cool demo and audience was amazed about his demo.


After that, we had another back to back session from Kaushal Bhavsar. He had presented about how we can create a secure two factors authentications with  Azure technologies. He had some given some cool demo using Azure Active directory and Office 365 account authentication about it.


After that we had tea and It’s time for Ahmedabad User group president Mahesh Dhola to rock the stage. Instead of giving demo he chooses to use WhiteBoard and given presentation DevOps and Microsoft Azure. It was fun watching is him presenting the topic that we all love.


After the presentation, it was the time where everybody wants to get some prize. We had the lucky draw and almost everybody gets price.


And this guy was an inspiration for all us.


Then we has some photos of all the speakers. We missed Jagdish here as he needs to go home for some personal work.


Overall, It was a fun event. We had some much fun hacking and learning something new. Thank you, Microsoft and Ahmedabad user group for hosting such a nice event.

Keep rocking!.
Thursday, April 14, 2016

Visual Studio 15 Next version of visual studio is available now

With Build 2016 event, Microsoft has announced the preview of next version of Visual Studio called Visual Studio 15. You can download the next version of VS from below link.

There are two options available for there on above link for download. One is normal Installed which is traditional installer contains all the functionality of earlier version of visual studio.

The second option contains a new lightweight installer which a brand new install from the Microsoft focusing on making visual studio installation faster and-and less impactful. The smallest installation of the Visual studio is now under 500 MB and includes support for more than 20 languages. You can optionally add additional features like desktop development using  Windows forms and WPF.

P.S. This is a preview still Microsoft is working on that so you will not see lots of new features and its in preview so you should never use it for production.
There are some new features announced like Open Folder, Improvements of the debugger and few other stuff. You can see the complete list of features in release note at the following link.

On the same page, you can see the list of new features. That’s it. Hope you like it. Stay tuned for more!.
Wednesday, April 13, 2016

Come join us at - Global Azure Bootcamp 2016 Organized by Ahmedabad User Group

Do you want to be part of largest community event is the world? If Yes, then Global Azure boot camp 2016 is there. Ahmedabad User group is going to organize Global Azure boot camp.

The global azure boot camp is going to be organized at more than 180 locations worldwide. They are going to have some cool Azure lab. So I would encourage you to participate in that.

You can find more information about that following link.

If you want to participate in this one of the greatest event hosted by Ahmedabad User Group then you can register via the following  link.

Please create a pass for yourself and be there. I am also going to be there as a speaker and going to present about document DB.

So see you all there!
Thursday, March 31, 2016

Visual Studio 2015 update 2 is available for download now

Visual studio 2015 is a great IDE and I love that more and more. As we all know that visual studio update 1 was released few months ago, Yesterday at build conference Microsoft has announced  Visual studio 2015 update 2.

From where I can download Visual Studio 2015 update 2:

You can download Visual studio 2015 update 2 different editions from the following links.

Visual Studio 2015 Community Edition:
Web installer :
ISO  File:

Visual Studio 2015 Professional Edition:
Web Installer:
ISO File:

Visual Studio 2015 Enterprise Edition:
Web Installer :
ISO File:

Also, You can download visual studio update 2 only without whole editor from the following link.

There are lots functionalities new features provided for new updates. You can find a complete list of features the following link.

I am going to post about some new features in visual studio update 2 in forthcoming blog posts. Hope you like it and Stay tuned for more!.
Wednesday, March 30, 2016

Build 2016 Conference Live streaming

Microsoft continues to focus on enabling developers to do amazing work as businesses and industries transform in support of the shift to a cloud-first, mobile-first world. At Build 2016 Microsoft will present the latest tools and technologies and how they can help today’s developers be their most creative and productive.

From here you can see the live streaming  of build conference 2016.

Friday, March 25, 2016

How to use syntax highlighter with open live writer

Microsoft has open sourced windows live writer as “Open Live Writer” and is now part of .NET Foundation, It was a great move but as a part of modernizing the windows live writer they have started removing the functionality and adding some new functionality. Eventually, they are going to add the plugins but right now there is no support for that. I have been using windows live writer for more than 5 years now and I was using syntax highlighter for highlighting code on this blog. If you are not familiar with syntax highlighter you can find more information on the following link.

It is a fully functional self-contained code syntax highlighter developed in  JavaScript. As now Open writer does not support plugin for the time being, I have to find another solution to write the blog post and do some syntax highlighting. So, I have found a way to do this and I would like to share this with you. In this blog post, we are going to learn how we can use syntax highlighter other way.

I was using preCode syntax highlighter plugin. It’s an open source plugin and provides a great plugin for syntax highlighter.

But as Open Live Writer does not support plugin, There is no way to directly Integrate that plugin, But fortunately, precode syntax highlighter plugin comes with a desktop application was so now you can run that desktop application via finding it on windows 10 like below.


Once you run the preCode Code manager desktop app, It will run the application like following.


Here you can put your code make settings as per your choice on the right side like below.


Then just click on the copy to clipboard and close. It will copy syntax highlighter code in the memory.  Now click on source tab at the bottom on the open live writer like below.


Then paste that code like below.


And now publish your post and it will look like below.
function helloWorld{
    alert("hello world");
That's it. It is very easy to use precode code manager with the open live writer. Hope you liked it. Stay tuned for more!.
Friday, November 27, 2015

TypeScript configurations in Visual Studio Code

Before sometime I have blogged about - Why It's the right time to learn Typescript and It does get lot of buzz. Typescript getting every day more popular due to reason I have mentioned in above blog post.  So now in this blog we are going to learn how we can use TypeScript with new Visual Studio Code editor.

TypeScript support in Visual Studio Code:

As you know Visual Studio Code is in beta now and provide great support for typescript. Here you can operate TypeScript in two modes.

1) File Scope:

In this mode Visual Studio Code will treat each typescript file as separate unit. So if you don't reference the typescript files manually with reference or external modules it will not provide intellisense as well as there will not common project context for this.

2) Explicit Scope:

In this scope we are going to create a tsconfig.json which will indicate that folder in which this file exist is a root of TypeScript project. Now you will get full intellisense as well as other common configurations on tsconfig.json file.

You can create a new file via File->New file from Visual Studio Code and add following code about TypeScript configuration under compiler operations.
    "compilerOptions": {
        "target": "ES5",
        "module": "amd",
        "sourceMap": true

Converting TypeScript into JavaScript files automatically(Transpiling ):

Now as we all know that TypeScript is a super set of JavaScript and this files we can not directly put into html page. As browser will not understand the typescript itself. So we have to convert it into JavaScript. So to convert TypeScript file into JavaScript file we need to configure a in built task runner which will automatically convert all the TypeScript files into JavaScript.

To configure Task Runner you can either press F1 or Ctrl+Shift+P and type task runner. Configure Task runner will popup.


Once you press enter it will create a .vscode folder and create file called task.json which will have following code.
    "version": "0.1.0",

    // The command is tsc. Assumes that tsc has been installed using npm install -g typescript
    "command": "tsc",

    // The command is a shell script
    "isShellCommand": true,

    // Show the output window only if unrecognized errors occur.
    "showOutput": "silent",

    // args is the HelloWorld program to compile.
    "args": ["HelloWorld.ts"],

    // use the standard tsc problem matcher to find compile problems
    // in the output.
    "problemMatcher": "$tsc"

Now when you build your project it will create a JavaScript file automatically. Now Let's create a TypeScript file like following.
class HelloWorld{
        console.log("Hello world:" + name);

Here you can right now there is only one file there in explore section.


Now when you build the project with Ctrl+Shift+B. It will create a JavaScript file.


and Following is a code for the same.
var HelloWorld = (function () {
    function HelloWorld() {
    HelloWorld.prototype.PrintMessage = function (name) {
        console.log("Hello world:" + name);
    return HelloWorld;

Hiding JavaScript File from explore area in Visual Studio Code:

I don't like my JavaScript file to show in explore area as we already have TypeScript file. So we don't have to worry about JavaScript file. There is a way to hide JavaScript file and I have to add following code in my user settings file. Which you can get it via File->Preferences->UserSetting
"files.exclude": {
"**/.git": true,
"**/.DS_Store": true,
    "when": "$(basename).ts"
Here in above I have written custom filter for excluding JavaScript file when TypeScript file is present. Now it will not JavaScript file even if they exists on disk.


That's it. Hope you like it. Stay tuned for more!!. In forthcoming post we are going learn a lot of TypeScript.
Sunday, November 8, 2015

My Entity framework blog series

Saturday, November 7, 2015

Working with transaction in Entity Framework 6

In  any Relation database, maintaining the integrity of the database is very important and Transaction is one way of maintaining database integrity. When you have the situation, where you need to insert data into multiple tables and if inserting a data in one of the table fails you should always rollback other inserts transaction becomes very useful. The Same scenario can occur for update or delete operations. If transactions are not there you will end up with lots of junk data in tables. Entity framework is one of most popular ORM in Microsoft.NET World. So in this post, we are going to learn how we can use transactions with Entity Framework 6.

Transaction and Entity Framework 6:

Entity framework internally maintains a transaction when you call SaveChanges() method. So all Inserts, update operation under single save changes method call will be in a single transaction. But when you want to wrap multiple SaveChanges() method under single transaction there was not inbuilt functionality in the earlier version of Entity framework. We have used to use TransactionScope class for the same.

But now with Entity Framework 6.0, We have two inbuilt APIs for Transaction.


It allows us to Begin transaction for multiple save changes, You can combine as many operations as you want under the single transaction and hence either all will be performed successfully then the transaction will be committed  and if any exception occurred than transaction will be rollback.

DbContext.Database.UseTransaction :

Sometimes we need to use a transaction which is started outside of the entity framework. In this case, this option allows us to use that transaction with entity framework also.

In this blog post, We are going to use Begin Transaction. I will write a separate blog post about how to use existing transaction with entity framework.

So enough theory, let's create a console application understand it better.


We need entity framework. So I have added it via NuGet package.


In this application, we are going to use two model classes category and product. We will save them both in the single transaction and try to understand how the transaction works with Entity Framework.
namespace EFWithTransactions
    public class Category
        public int CategoryId { get; set; }
        public string CategoryName { get; set; }
And here is product model.
using System.ComponentModel.DataAnnotations.Schema;

namespace EFWithTransactions
    public class Product
        public int ProductId { get; set; }
        public string ProductName { get; set; }
        public int CategoryId { get; set; }
        public virtual Category Category { get; set; }

Here you can see I have category id there in product and a product is belong to category and I have created my DB context class like following.
using System.Data.Entity;

namespace EFWithTransactions
    public class ProductDbContext : DbContext
        public ProductDbContext()
            : base("ProductConnectionString")

        public DbSet<Category> Categories { get; set; }
        public DbSet<Product> Products { get; set; }

And following code is for Main method of console application, Which illustrate real times scenario where exception might occurs during multiple save changes().
using System;

namespace EFWithTransactions
    class Program
        static void Main(string[] args)
            using (ProductDbContext productDbContext = new ProductDbContext())
                using (var transaction = productDbContext.Database.BeginTransaction())
                        //saving category
                        Category category = new Category
                            CategoryName = "Clothes"

                        // Throw some error to check transaction
                        // Comment this to make transactions sucessfull
                        // throw new Exception("Custom Exception");

                        //saving product
                        Product product = new Product
                            ProductName = "Blue Denim Shirt",
                            CategoryId = category.CategoryId
                        Console.Write("Cateogry and Product both saved");
                    catch (Exception exception)
                        Console.WriteLine("Transaction Roll backed due to some exception");

If you see above code carefully, you can see I have two save changes method one for category and another for the product. Also, I have used BeginTransaction method to initiate a new transaction. I have put one custom exception to illustrate something is wrong with that transaction. Also, try catch block is there so if any exception occurs catch block will rollback the transaction. If all went well it will commit the transaction.

Now let's run this application and following is an output as expected. As we have thrown an exception.


And there is no data inserted in database also.


Now let's comment the throw new exception part.
//throw new Exception("Custom Exception");

And now let's run our application again and here is the output as expected.


And now we have data in the database there.


So now we have a really good way to use transaction in entity framework. Hope you like it. Stay tuned for more!.
You can find complete source code of above blog post on github at -
Friday, November 6, 2015

How to use stored procedure with Entity Framework Code First

I'm getting lots of request from readers of my blog about writing blog post about how to use stored procedure with entity framework code first. So in this blog post we're going to learn about how we can use stored procedure with Entity framework code first.

To demonstrate that we are going to use create a table called Employee like following.

And here is the create table script for the same.
CREATE TABLE [dbo].[Employee](
[EmployeeId] [int] NOT NULL,
[FirstName] [nvarchar](50) NULL,
[LastName] [nvarchar](50) NULL,
[Designation] [nvarchar](50) NULL,
[EmployeeId] ASC

And following is the data I have inserted there.


And here is the store procedure we are using for that.
CREATE PROCEDURE usp_GetAllEmployees
SELECT EmployeeId,FirstName,LastName,Designation FROM Employee

Now we have already done with our database side, it's time to write some C# code. I'm going to use simple console application for the same.


Now It's time to add entity framework via nuget package .


Here is the model class I have created.
namespace CodeFirstStoredProcedure
public class Employee
public int EmployeeId { get; set; }
public string FirstName { get; set; }
public string LastName { get; set; }
public string Designation { get; set; }
And then I have created entity framework dbcontext like following.
using System.Data.Entity;

namespace CodeFirstStoredProcedure
public class EmployeeDbContext : DbContext
public EmployeeDbContext()
: base("EmployeeConnectionString")

public DbSet<Employee> Employees { get; set; }
And following is a code for using stored procedure to get data from database via entity framework code first.
using System;
using System.Linq;

namespace CodeFirstStoredProcedure
class Program
static void Main(string[] args)
using (EmployeeDbContext dbContext = new EmployeeDbContext())
string commandText = "[dbo].[usp_GetAllEmployees]";
var employees = dbContext.Database.SqlQuery<Employee>(commandText).ToList();

Console.WriteLine("Printing Employee");
foreach (var employee in employees)

Here in the above code, If you see care fully. I have used SQL Query function to execute stored procedure and that will return a list of employee. Then I have printed this list with console.writeline.  Now when you run this application, output will be as expected.


That's it. It's very easy to use stored procedure with entity framework code first. Hope you like it. Stay tuned for more!!.
You can find complete source code of this sample application at - following location -

Support this blog-Buy me a coffee

Buy me a coffeeBuy me a coffee
Search This Blog
Subscribe to my blog


My Mvp Profile
Follow us on facebook
Blog Archive
Total Pageviews