Pages

Wednesday, April 29, 2015

Hi All – I wanted to let you know about a great free event that Microsoft and the MVPs are putting on, May 14th & 15th. Join Microsoft MVPs from the Americas’ region as they share their knowledge and real-world expertise during a free event, the MVP Virtual Conference.

The MVP Virtual Conference will showcase 95 sessions of content for IT Pros, Developers and Consumer experts designed to help you navigate life in a mobile-first, cloud-first world. Microsoft’s Corporate Vice President of Developer Platform, Steve Guggenheimer, will be on hand to deliver the opening Key Note Address.

Why attend MVP V-Conf? The conference will have 5 tracks, IT Pro English, Dev English, Consumer English, Portuguese mixed sessions & Spanish mixed sessions, there is something for everyone! Learn from the best and brightest MVPs in the tech world today and develop some great skills!

Monday, April 27, 2015

I had a really hard time installing Ubuntu 14.04.2 LTS (Desktop x64) on Hyper-V and configuring it to connect to Internet. Of course the installation was smooth, but configuring the Ubuntu to have Internet was a disaster for me. Have read many articles, tried different scenarios and got myself into a mess with multiple virtual Internal and External switches. Started to hate Hyper-V, but apparently, things went well.

And this is a step by step guide for you to start from scratch. Please not that, I am not going to go in detail about creating a virtual machine on Hyper-V.

I will be explaining the process with External and Internal virtual switches.

External Virtual Switch

My environment is Windows 8.1 with a working Wi-Fi connection. No previously created Internal or External virtual switches.

The version of Ubuntu I am going to install onHyper-V is, Ubuntu 14.04.2 LTS (Desktop x64).

In New Virtual Machine wizard, in Configure Networking, I am selecting Not Connected.

New Virtual Machine Wizard

Installation Summary

Now do the installation, in the middle of installation, you can see that you don’t have internet. That’s of course obvious.

Not connected to Internet

Once installed, for worse case, shut down the newly created Ubuntu virtual machine. (You actually don’t have to shut it down and you still can move ahead with below, but let’s just shut it down.)

In Hyper-V click on Virtual Switch Manager.

Virtual Switch Manager

There, create a new External virtual network switch.

New External Virtual Switch

In the next step, give a name, I am using External Virtual Switch, and I am selecting my Wi-Fi adapter to be used in virtual switch and allowing sharing as below.

External Virtual Switch Properties

Click on Apply and Ok.

Network Connections

Once it got created, Right click on vEthernet (External Virtual Switch) connection, click on Properties, go to Sharing tab. Please note that I am not doing any changes here, and I am keeping it as it is. In some articles, they say that you need to tick the checkboxes and do the allowing. There is a scenario, which you really need to enable these, and I am describing that later in the post. Hang on!. So for now, I am keeping this as it is.

vEthernet (External Virtual Switch) Sharing

Right click on Ubuntu Virtual Machine and click on Settings. It will look like below.

Virtual Machine Settings

Now set the Virtual Switch property to created External Virtual Switch.

Virtual Machine Settings

Click on Apply and Ok.

Now start the Ubuntu virtual machine back again and now you should have internet.

Now let’s see what are the Wired Connection properties in your Ubuntu machine. You should be seeing the following. In IPv4 Settings tab, Method is Automatic(DHCP).

Wired Connection IPv4 Settings

And when you check Connection Information for Wired Connection, you can see that a IP address is assigned, and the Gateway(Route) and DNS is assigned with your routers settings.

Wired Connection Information

Now let’s say, you still don’t have internet for some reason. Here is a workaround.

First go to vEthernet (External Virtual Switch) properties and do the allowing as below.

vEthernet (External Virtual Switch) Sharing

Run a ipconfig on command prompt and get the vEthernet (External Virtual Switch) values.

ipconfig

In Ubuntu machine, let’s manually configure the IPv4 settings as follows. And of course, you need to replace these with yours.

Wired Connection IPv4 Settings

Gateway is the IPv4 address of vEthernet (External Virtual Switch) or you can use the Default Gateway of vEthernet (External Virtual Switch). When you use the IPv4 address of vEthernet (External Virtual Switch), that means you are going out through vEthernet (External Virtual Switch), so you should do the allow sharing on vEthernet (External Virtual Switch) connection. When you use the Default Gateway of vEthernet (External Virtual Switch), that means you are going out through the router and not using the vEthernet (External Virtual Switch). And then of course, you don’t have to do the allow sharing on vEthernet (External Virtual Switch) connection on Windows. So the rule here is, if you are going to use the IPv4 address of vEthernet (External Virtual Switch) as your Gateway here, you need to do the allow sharing on vEthernet (External Virtual Switch) connection on Windows. Here since, I have done the allowing, I am using the IPv4 address of vEthernet (External Virtual Switch) as the Gateway.

For DNS, I am setting as 8.8.8.8 or it can be the same as the DNS of vEthernet (External Virtual Switch) which is 192.168.0.254 in my scenario.

Wired Connection Information

So, that’s it. Now you should have Internet.

Internal Virtual Switch

So this is how you can configure the Ubuntu virtual machine with a Internal switch. For this you will have to shutdown the Ubuntu virtual machine and do the following.

Create a new Internal Virtual Switch in Hyper-V. I am naming it as Internal Virtual Switch.

New Internal Virtual Switch

Click on Apply and OK.

Open up properties of vEthernet (External Virtual Switch) and do the allow sharing with newly created vEthernet (Internal Virtual Switch).

vEthernet (External Virtual Switch) Properties

Open up the properties of vEthernet (Internal Virtual Switch) and inside Internet Protocol Version 4 (TCP/IPv4), make sure the IP Address to look something like below. When I allow sharing of vEthernet (External Virtual Switch) with newly created vEthernet (Internal Virtual Switch), for me the default IP Address of vEthernet (Internal Virtual Switch) was in a different network range. So I have changed it as follows.

Switch on the Ubuntu virtual machine. Make you’re your connection properties look like below. If Automatic(DHCP) doesn’t give like below, you will have to assign IPv4 Settings manually. For me it was not, so I am in the Manual mode.

Wired Connection Properties

Give an IP address, and here the Gateway should be the IP Address of vEthernet (Internal Virtual Switch). DNS Servers can be either, public DNS which is 8.8.8.8 or the IP Address of vEthernet (Internal Virtual Switch) which is 192.168.0.100 for me. So my wired connection summary is like below.

Wired Connection Information

Now you should have Internet.

Please note that, sometimes, you will need to disconnect and reconnect the Wired Connection for changes to be effected. Once you got the concept, it’s possible for you to rearrange the above steps to match your need. And of course, rather than starting fresh with no previous Internal/External switches created, you can start the whole process with previously created Internal/External switches.

Saturday, April 25, 2015

Whilst Global Azure Bootcamp were happening all around the world on Saturday, April 25, 2015, set of Sri Lankan MVPs’ has organized Global Azure Bootcamp on Colombo, Sri Lanka as well. Microsoft had a total of 183 confirmed event locations for Global Azure Bootcamp, 2015.

Following is the list of speakers who delivered their sessions on the Sri Lanka’s Global Azure Bootcamp.

List of Speakers

I was privileged enough to deliver a session there along with one of Sri Lanka’s most senior MVPs Fiqri Ismail.Fiqri is a MVP in ASP.NET/IIS for 9 consecutive years.

Fiqri has started off with the session giving an introduction to Azure websites, and after giving an introduction, I have demoed how we can publish an ASP.NET application to Azure using Visual Studio. Then showed how we can create a Azure web site using Azure current portal and how we can integrate it with GitHub. Fiqri wrapped up the session, explaining different Azure Web Stacks and demoing how to access Visual Studio Online “Monaco” from the new Azure Portal .

Sunday, April 5, 2015

We have been using .NET framework since 2002 (.NET Framework 1.0) which was released along with Visual Studio 2002. It has amazingly evolved over time and as of today, we are in the age of .NET 4.6 Preview which was initially released with Visual Studio 2015 Preview. Last November, being specific, 12th November 2014, along with the .NET 4.6, Microsoft has announced another framework which is .NET Core.

So what’s this .NET Core? Let’s find out.

If you have a look at the following picture, you should be able to get a basic understanding of how .NET framework is structured.

Overview of .NET Framework

The .NET framework is a collection of set of verticals such as Windows Desktop, Windows Store, Windows Phone, ASP.NET 4 etc. and for each these verticals there are different Base Class Libraries (BCL) and runtimes (for Windows Desktop and ASP.NET 4, basically it’s the same framework and runtime). Some libraries are available in one vertical and those same libraries are not available in other. Best example for this scenario would be Windows Store and Windows Phone. Isn't it great if we can have a single Base Class Library, that can be used across every vertical/application model regardless of the application model and the operating system that the application runs upon.

And that’s where the .NET Core comes in.

Overview of .NETCore

In simple, .NET Core is a framework which includes all the core and primary libraries which is available in all the different Base Class Libraries in .NET full framework. So with .NET Core there will be no different Base Class Libraries, there will be only one unified BCL which can be used in Windows Desktop, Windows Store etc. application models and most importantly it can run on Windows, OS X and Linux. Here there is a runtime adoption layer, that’s because for Windows 10 Universal apps, the runtime will be .NET Native and for ASP.NET 5 on .NET Core, the runtime will be Core CLR.

Another things is, the .NET Framework is a machine-wide framework. Any changes made to it affect all applications taking a dependency on it. If you upgrade the .NET Framework version in your machine, there is no 100% guarantee that applications which targets the old frameworks still works.

.NET Core answers this question by giving the ability to be shipped via NuGet. That means you can ship a private version of the .NET Core Framework with your app. Other apps' versions can't change your app's behavior. Here the nice thing is, the entire .NET Core platform is not distributed as a single NuGet package. Instead, it’s a set of fine grained NuGet packages. In simple with the .NET Core, you are building your own framework.

Now let’s see .NET Core in action. For that, let’s create an ASP.NET web application using Visual Studio 2015.

When you try to create a ASP.NET application using Visual Studio 2015 targeting .NET Framework 4.5 or above, you will see following project templates.

New Project

Let’s move forward selecting an ASP.NET Web Application and you will be thrown with the following dialog. There let’s choose ASP.NET 5 Empty and click on OK.

New ASP.NET Project

Once we do that, a new ASP.NET Web Application will be created and it is slightly different to ASP.NET 4 or below Web Application project templates. There is no longer a web.config file, instead there is a project.json file. Under the solution explorer if you expand the References node, there you will see the following.

ASP.NET 5.0 and ASP.NET Core 5.0

There you should be able to see ASP.NET 5.0 and ASP.NET Core 5.0. In here basically ASP.NET 5.0 will be running on top of .NET Framework 4.5 and ASP.NET Core 5.0 will be running on top of .NET Core 5.

Consider that you have the following two entities and the data context.

publicclass Person

{

publicint Id { get; set; }

publicstring Name { get; set; }

publicvirtual Hobby PrimaryHobby { get; set; }

publicvirtual Hobby SecondaryHobby { get; set; }

}

publicclass Hobby

{

publicint Id { get; set; }

publicstring Name { get; set; }

publicvirtual List<Person> People { get; set; }

}

publicclass MyDbContext : DbContext

{

public DbSet<Person> People { get; set; }

public DbSet<Hobby> Hobbies { get; set; }

}

When a database is created from the above model, you will be getting a database like below.

Database

There is nothing wrong with this model. Since we have exposed “People” property of type List<Person> in the “Hobby” entity, Entity Framework is creating a foreign key inside “Person” entity named “Hobby_Id” along with the foreign keys “PrimaryHobby_Id” and “SecondaryHobby_Id”.

But what if this is not what you want. Instead, Let’s say when you want to get all the people having a specific hobby, you only want to get the people in who’s primary hobby is that particular hobby. For that there should be a relationship between “People” property in “Hobby” entity and “PrimaryHobby” property in “Person” entity. And that’s where the InversePropertyAttribute comes in.