Migrating to Identity Core 2.0

Migration to ASP.NET Core Identity 2.0 is an important part of migration to ASP.NET Core 2.0 is. In our case of migration, we had to migrate from “AspNet Full Framework” to “AspNet Core 2.0”. All entities (models) in our case have to inherit from a specific base class and implement a specific interface. So adapting Identity to this, needs special considerations.

IdentityUser generic signature

First shocking change I saw, was IdentityUser. Former one allowed to introduce all other identity entities via its generic signature. Like this:

But Identity Core has changed it to:

It was easy to handle but in first glance it shocked me! This signature is not needed any more. Introducing it in just IdentityDbContext is enough:

New entities and field type changes

Identity Core 2.0 has introduced 2 new entities: RoleClaim and UserToken. Also date time columns in database tables have been changed to datetime2(7). Other changes also happened. For example, Role has 2 new fields, ConcurrencyStamp and NormalizedName.


Generating JWT seems to be easier than .Net Framework and OWIN. Formerly we have been using:

While a sample code for generating JWT in ASP.NET Core 2.0 is like this code (inspired from here):

BTW it seems that JWT consumption has not been changed a lot. In .Net Framework/OWIN we had UseJwtBearerAuthentication and in ASP.NET Core 2 we have AddJwtBearer. They both accept some configurations.

See a sample generated JWT using ASP.NET Core 2.0 below.


Choosing a new development platform for a .Net developer

I'm evaluating some programming languages to learn instead of Microsoft .Net. I'm a software developer with more than 10 years of commercial software development experiences mainly in Microsoft .Net platform. I have worked both as employee and as freelancer. Now for some reasons I'm interested to learn something new other than Microsoft .Net. Some of reasons are:

  • Moving to a new company may need knowing new programming languages and development platforms

  • Getting a remote job or project will potentially lead me to learn something other than Microsoft .Net

  • My own start-up projects and custom software development projects may be done easier and more agiler with help of technologies like Node.js or Rails/Ruby.

  • I have a passion on Linux and .Net is not fully available on it yet by Jan. 2016.

  • Moving to a new city or to a new country needs me to have a broadest skill sets.

  • I need to do something new!

My main experiences are in web application development specially in back-end. So I have developed lots of code and pages in ASP.NET Web API, ASP.NET MVC, ASP.NET WebForm and even Nancy. Also have experiences in WPF/MVVM and JavaScript.

It's near a year that I'm trying to switch to Ubuntu and finding a good alternative to .Net. First thing first I liked to have .Net in Ubuntu but it is not complete yet and it may need few years to be fully available and adopted by the community. I did a technical comparison between Ruby, Python and Node.js but in realty I need to make attention to job market too. A good software development platform is a platform that has good community adoption and good salary too.

Along this journey I tried to get my hands dirty with my favorite platforms with help of quick starts. Quick starts are good points to learn programming languages. A typical quick start learns you how to setup the platform from scratch, how to develop a basic application with it and lets you get acquainted with concepts and tools. I started with my most loved technology Rails/Ruby. Tried to get a bit deeper on Rails but after a while suspected is it a better to learn something that already can be used in my projects? So tested Node.js a bit.

Last week I thought twice about priority number 1, moving to a new company. Major IT companies in the country that mostly are in banking, financial and government field prefer Java for their projects. Many of their projects are enterprise level and no surprise they prefer Java over other platform. So after getting hands dirty with Rails and Node.js I got Java installed in my machine and built a simple basic hello world with Java, Eclipse, Hibernate and Play. Play felt very similar to Rails which Rails itself felt similar to ASP.NET MVC.

Playing with Java showed me that Java is not very strange for a long term C# developer. This sense was common when trying Rails and Node.js specially when regarding with Web development. Rails, Play and ASP.NET MVC are very similar to each other as they are base on MVC pattern. In other hand C# and Java are very similar languages with similar internal structures. Also Node.js is not very un-familiar for developers with front-end development experiences. IDEs of all this platforms are not very different at root. Batteries and equivalent components exists.

After all I concluded that switching to platforms like Rails, Node.js, Java, Python and PHP is not a hard or time consuming task for .Net developers that have enough software development experiences. It may be reasonable to wait for a job position or a development project then getting more deeper with desired platform.

Trying new programming languages and platforms

With about 10 years of developing software in Microsoft .Net platform since 2005, I decided to try something new. Microsoft .Net, C# and ASP.NET are my good friend but I think they are not very fast in agile world and in fast growing startup demands. Also Microsoft .Net essentially require Windows eco system that is not free to use that can be problematic specially in countries that are sanctioned to buy legal licenses and is not rich enough to pay the prices.

As a mainly web developer I decided to gather more information on Ruby, Python and Node.js. They all have rich library of components and reusable components and batteries and also can be developed and hosted in a Linux machine. A good decision needed to me to get hands dirty and try them practical. My first try was Ruby/Rails. A small database driven web project was offered to me to evaluate and estimating the price. It was good situation to do it in Ruby/Rails especially I am an ASP.NET MVC developer and I was not un-familiar with MVC pattern. Finding good tutorials I started installing Sublime Text and Rails on my Ubuntu machine and exploring Ruby/Rails. The project I were offered to evaluate go cancelled finally but I learnt good thing about Ruby/Rails. Rails itself id pretty much similar to ASP.NET MVC. Controllers and Views (erb files) were pretty similar to ASP.NET MVC Controllers and Razor views (cshtml). Previously in an ASP.NET WebForms project, our team were using Castle ActiveRecord over NHibernate for data access. So Rails’ ActiveRecord pattern was also very similar.

Never had situations to try Python yet. Even I may remove it from my to-try-list. Because I see no business opportunity on it yet. In the other side I have a chance to install and use some portions of Node.js (npm) on my machine while trying AngularJs that will describe it later in this text. BTW as times go on I’m thinking that it’s better to wait for a new project or job position that needs or fits into a certain language/technology then try to learn and master it. This is mainly because my job position is not very stable now and may have changes soon.

As I’m deciding it’s better to learn a new language/tools when a new project arrived or a new job position is offered I started to try AngularJS as I’m offered to do sections of a web project in SPA style. First decision was selecting a good framework. Mine was AngularJs. Though Angular 2 is not finalized yet I decided to use it because our product is not very large and sensitive and will not be in production very soon. Using TypeScript over CoffeeScript was my second decision as it tied with Angular 2 and is very similar to C#. I guess I will use a little Angular 2/TypeScript in this project because main requirements of the project are satisfied with use of Angular routing module.

My journey is not finished here. I may try Perl too as my favorite help desk software, OTRS is written with Perl and a time in future I may develop some plugins for it.