First OSS Pull-Request Accepted

I am very happy to announce that my first OSS pull-request has been accepted by Microsoft 🙂


The painful way of migrating to dotnet

Recently I started to checkout the newer version of Microsoft dotnet. However, the tooling [Visual Studio / VSCode] were all like, you have to be connected to the internet and also need to be updated. Few of the packages are moving the bleeding edge, the remaining still lagging behind.

As a normal developer that is used to .Net Framework 4.7, it really is a worst experience, as you get all weird errors, but no help from Microsoft groups. I ran into this while running a test case in XUnit where there is a huge mess. I made a simple check-in for ASP.NET Security which took 1 hour but trying to setup debugging and running the tests have taken approx 2 days and not yet successful.

Given this much pain, it will be worth moving to a different language and trying to get up to speed as I was never expecting Microsoft to screw up the developer’s life so bad with the newer versions.

Configuration Aspects in Multi-Tenancy

In Multi-tenancy, the following are some of the aspects that are linked to the configuration of the application that needs to be delivered as a SaaS application.

Custom configuration

1.1 User Based Configuration

In case you are planning to allow the user’s to custom configure the application, they have to be maintained on a per-user basis and in case of one user having access to different companies [tenants in Multi-Tenancy], you will also have to isolate the data by tenant and user combination

There are various levels like flipping switches by a user that turns on and off of a functionality to even licensing the product at a user level. The former will require a user based discretion alone. However, the latter one may require a workflow like a model where a user can raise a request for a feature from his admin and the admin approves the same and then the user gets to access the newly requested feature

1.2 Tenancy Based Configuration

In case of a tenancy based model of customization, there will be multiple levels like having a company [tenant] to subscribe to plans to gain access to the various application features.

Additionally, the tenant will have to configure the company workspace like providing the credit card details for payment, email configuration for the company specific emails etc. This also involves the flipping of ON / OFF switches which in turn make the functionality work more dynamically

  • Regarding the several applications you have plans for, they do require SSO and also the flow of the configuration and company specific data across the applications. There can be company [tenant] specific database which needs to be stored and maintained for which the Azure Shard Map or similar ones can be used.
  • There is a code base scaling which can be configured on-demand by your PaaS provider like Azure. However, the application needs to be developed in a fashion so that it can support database partitioning and scaling. This will have to take into account the factors like data-isolation etc.

There are various PaaS providers which needs to be decided based on your exising and future / predicted user base and then the same can be decided and opted for.

Microsoft has some nice articles for Multi-Tenancy given below

Entity Framework Versus Dapper

Comparison of Dapper Versus EntityFramework

Being authored an authorization server for Multi-Tenant SaaS Applications, one fine day, I was doing application profiling and noticed in profiler, that the context loading was taking more time, rather than rewriting the same in ADO.Net for critical requests that are required to handle data faster, I thought I would opt for Dapper.

Dapper had a simple wrapper over the SQL Connection that takes the Query and the paramters [SQL Paramters for parameterized Query]. I found dapper simple and interesting. Deciding to try out Dapper in a similar environment than replacing in the exising ones, I did a couple of benchmarks of Dapper Versus EntityFramework and the following are the observations.

Method Job Jit Mean Error StdDev Median
GetClientDetailFromDapperDAL_Async LegacyJitX64 LegacyJit 243.2 us 4.817 us 5.354 us 243.8 us
GetClientDetailFromEFDAL_Async LegacyJitX64 LegacyJit 465.5 us 9.258 us 24.390 us 457.1 us
GetClientDetailFromDapperDAL_Async RyuJitX64 RyuJit 237.6 us 2.447 us 2.169 us 237.6 us
GetClientDetailFromEFDAL_Async RyuJitX64 RyuJit 465.6 us 9.022 us 12.940 us 465.1 us

The source code for this analysis will be posted shortly.

My views on F#

The below given points are what I felt when I started with F#. Since I am still learning about F#, these may sound absurd or weird to the Masters or geeks in F#.

1. I am a C# developer, sought to learn functional programming, started with Scala and got advice from great people and moved to F#, i’ m still fiddling around
2. I am not finding easy when handling the interfaces. It’s not as easy in C#, I.e. when passing around the interfaces or trying to create a reference to an object using its interface.
3. Returning a Task is a bit difficult in F# ( FOR ME). Methods like return Task can’t have a Task.FromResult<object>(null) like in C#.
4. Interoperability with C#, I mainly use lambda’s (Action & Func), as F# function is different from C# Func.
5. I stumbled upon an issue recently, I.e. there should not be even an empty file in F# project. This is because of the multiple modules convention
6. Ordering of the files in the project is like sequential, which is a bit difficult to follow coming from C#
7. IDE support for dll method signature lookups are required, most of the time, I’m hitting on F12 to see the signature which does not show up in the IDE
8. Big concern is since latest versions of C# are borrowing the concept from F#, will F# fade away with time and C# become a functional cum imperative language.

Please note that, these are my ideas and thoughts, I don’t find fault with anyone, as I am a learner still.

Tips for SQL Server

Showing the SQL Statistics in XML

To show the query plan


To Show the execution times for a query, wrap the query using the below




Sample Query with CTE

WITH URT_CTE (AssignedTo, RoleId, AssignedBy,UserId)
SELECT distinct urt.userroletenant_stratifiedtenantid AS AssignedTo,ur.userrole_roleid AS RoleId, urt.userroletenant_roleassigningtenantid AS AssignedBy, Ud.User_UserId as UserId
FROM userroletenant AS urt
INNER JOIN userroles AS ur ON ur.userrole_id = urt.userroletenant_userroleid
INNER JOIN userdetails AS ud ON ud.user_userid = ur.userrole_userid AND ud.user_userid=@userId
WHERE urt.userroletenant_roleassigningtenantid=@tenantid

Select AssignedTo From URT_CTE

Getting started with aspnet Core 1.0

Getting Started with ASP.Net Core 1.0

Today, I got started with the core 1.0. I have been using the .net version 4.6.1. Since, the official release is out, I thought that it may help me in learning and getting accustomed to this model so that I can migrate the code that I work day in and day out to reflect the latest

The following are the steps that I did

1. Downloaded the core 1.0 for windows [Not visual studio one, though I have VS 2015]
2. Installed the Visual Studio Code
3. created a new folder as per mentioned in the microsoft document
mkdir aspnetcore
cd aspnetcore
dotnet new

4. The step3 was completed with a couple of files like project.json and program.cs etc
5. I added the Kestrel Web Server and then registered the same in json file
“Microsoft.AspNetCore.Server.Kestrel”: “1.0.0”,
6. I created a new dummy middleware to test out the OWIN pipeline
app.Run(context =>
return context.Response.WriteAsync(“Hello from ASP.NET Core!”);

7. now i called dotnet build from the same command prompt
8. Then, I need to call dotnet run so that the source code is built and run in a port, typically port # 5000.
9. Things went well. I thought, it was enough for a hello world
10. I had to really create a WebApi and test. I created a new Folder for storing the models, controllers
11. Once the code for the above are done, I am still using VSCode, as expected, there will be build errors when running “dotnet build”
12. I had to add MVC somehow to the project, I guessed it should be within the project.json file, so googled and added
13. Then it seemed that I had to add MVC to the request pipeline so that I can access the above built in Api
14. I tried app.UseMvc() within startup > Configuration as I usually do in the previous versions [No googling done so far]
15. I got the message that AddMvc should be within ConfigureServices and as part of the IServiceCollection
16. Added that and the routes as well
17. Built and ran the app, viola, things were working fine!!!

Got a good start with ASP.Net Core 1.0

Source Code URL :