Monday, 30 March 2015

Emailing support

A while back I was working with a colleague and we ran into an issue that required us to email a company for support.

My colleague expressed an interest in how I went about structuring the email and asked if I could write up my process for them, hence this blog post.

Structure

The way I structure any of my mails, to support or otherwise, is along the lines of:

  • Explaining reason for the email
  • Provide any information I may have on subject
  • If asking for something clearly state what I need/would like

In addition if I am able to provide anything to help, such as test project with failing tests, they should be attached or easily accessed.

One of the additional things that I take into account when writing an email for support is thinking “what would I need to help

Example

Below is an example email written about a problem with a fictitious component aBxZ:

Hi Support,

Here at MadeUpCompany.com we are using your aBxZ component and are concerned about the number of duplicate calls it is making to the 123.com api and can see no way to stop this.

We have been using Fiddler to profile aBxZ’s behaviour on our QA environment whilst testing with a similar load to our production environment and have attached the data we captured.

If you look at the captured sessions you’ll see that aBxZ makes a call to 123.com for every request, this is happening even when we don’t call aBxZ explicitly.

We read the documentation and ensured that we have followed the instructions and guidance on how to use aBxZ and we posted on StackOverflow about it but nobody was able to provide a solution.

We managed to replicate the behaviour in a test project, which is attached, and it appears to be happening when aBxZ is instantiated.

Please can you let us know:

  1. Are we using the component correctly?
  2. If using it correctly is there anything we can do to stop this?
  3. If it is a bug with aBxZ when you think you might have a patch/fix

If we should be doing something different to what we do currently please could you alter the attached test project and send it back to us.

Looking forward to your reply

Analysis of the email

Looking at the mail it follows my structure and breaks down like this:

  • Paragraph 1, say who we are and what the problem is
  • Paragraphs 2 – 5 provide details about what has been tried and provide to them additional information in form of captured fiddler sessions and a test project
  • Paragraphs 6 & 7 ask, hopefully as clearly as possible, for help to resolve the issue.

Summary

Hopefully this is of use to you, for me it seems to be very clear but I’d be interested to hear from other people how they structure their emails and if you think I’m missed something out.

Thursday, 26 March 2015

Simple.Data Asp.Net Identity Provider

ASP.Net Identity is Microsoft's latest implementation of a membership and identity service which will replace ASP.Net Membership, SimpleMembership and Universal Membership.

The out of the box implementation of ASP.Net Identity is, unsurprisingly, coupled to Entity Framework (EF) which means if you do want to use the new identity functionality but your app doesn’t use EF for data access you either end up having to include it in your project anyway or not use Identity.

Simple.Data

On a project I was part of towards the end of last year we ran into this exact problem, we were using Simple.Data for data access but wanted to use the new features of Identity.

One of the advantages of identity over previous membership implementations is that it is possible to provide a different data access layer allowing you to use the database you want but keep the rest of the functionality provided by identity e.g. password encryption, OAuth, etc

The advantage of using Simple.Data is that you aren’t limited to connecting to any one database as you simply include the relevant provider for the database you want to use (if it is supported).

The Provider

The result is a Simple.Data provider for ASP.Net Identity which should be able to dropped into an existing application using EF with little to no change.

You can install it from Nuget using the package manager console with the following command:

PM> Install-Package Simple.Data.AspNet.Identity

If you prefer to use the “Manage Nuget Packages” GUI it is easiest to search for Simple.Data:

image

If you want to just look at the code or feel like building it from code yourself the repo on GitHub can be found here.

Limitations

There are a few limitations with this implementation that its worth knowing about:

  • Due to ASP.Net Identity being designed around generics you must use concrete classes with it, you cannot use dynamic.  To help the provider comes with 2 classes IdentityUser and IdentityRole classes for you to use.
  • Database tables – currently you need to use database tables that match the IdentityUser and IdentityRole classes although they don’t have to be named the same.  The Nuget package includes a script for Sql Server to create these tables.
  • Relies on referential integrity – when deleting data ASP.Net Provider does delete any data that may be effected, instead it relies on db referential integrity to clean up linked records.
  • Ids stored as strings – although ids for users, roles, etc are generated as Guids they are stored as strings, this mimics the standard EF model.
  • No IQueryable support – Simple.Data doesn’t support IQueryable this means that the Users property on UserStore and Roles property on RoleStore will throw not implemented exceptions.  If you need to query Users and Roles you need to do that yourself
  • Only works with Simple.Data v1 – a version is coming for Simple.Data v2 (which supports async await) but this is still a work in progress.
  • Db Connection – the provider supports using Simple.Data default connection or a named connection, it currently doesn’t support taking a connection string directly.

Although you need to use the identity classes in the provider you can inherit from them just like the EF code.

Samples

To try and make it as easy as possible to get started with this provider I have built 2 sample applications based off of the normal MVC project template:

  1. MVC 5 Standard Sample – this is the standard MVC project template the only change is that it uses Simple.Data for data access.
  2. MVC 5 Sample – this sample is an extension of the standard sample as it includes using roles with identity to be able to control access to pages of your web application

The easiest way to work with these samples is:

  1. Create new ASP.Net Web application
  2. Select the Empty project template
  3. Once the project has been created add the appropriate Nuget package

If you want the standard sample then at the package manager console type:

PM > Install-Package Simple.Data.AspNet.Identity.MVC5.Standard.Sample

Or if you want the sample that includes roles:

PM> Install-Package Simple.Data.AspNet.Identity.MVC5.Sample

When you install these packages you will have all the necessary classes and references added to your project and it will create a database in localDb so you should be able to build and run the code to start working with it immediately.

Both sample projects are in one repo which you can find here if you wish to play with the code that creates the samples although installing the Nuget package is by far the easiest way to get working with the code.

The future

This version is 1.0.0, it is stable and should work without problems (taking limitations mentioned into account).

Going forward there are several improvements that I intend to make:

  • Simple.Data v2 – complete work on this implementation
  • Support connection strings – to match normal Simple.Data connection options add the ability to be passed a connection string.
  • Support different id variable types – normal ASP.Net Identity allows for different variable types for ids via more generics, I’m looking to add this in.
  • Automated builds – looking to use AppVeyor to build and test the code
  • Automate Nuget publishing – once AppVeyor is building the code look to automate generation and publishing of the Nuget packages
  • More samples – add samples showing use of the provider in different ways e.g. not tied to Owin context

Summary

This provider should make it easy for people that wish to use ASP.Net Identity with Simple.Data right now.

With the planned future improvements the additional functionality will bring it up to parity with the full EF model.