Microsoft SQL Server Versions

While working with different clients, you often need to know which version of SQL Server they are using.

You can easily identify what is installed using the version number displayed either in management studio or querying it.

This list is not official but is very comprehensive and gives a lot of information on version and edition of currently installed items.

Have a look yourself on these builds (

It also lists other useful articles and links to related information.

Cannot open files in Microsoft Excel from SharePoint

Recently I uploaded a file in a document library on a SharePoint site. I had created a report and wanted to publish it. After reviewing client requested some changes in it, I tried to open that file from SharePoint directly in Microsoft Excel using “Open in Excel”.

Whatever I tried I always received an error “The file is corrupt and cannot be opened”. Did a little search on the web and found the solution.

  • Open Microsoft Excel
  • Go to File > Options
  • Click on the Trust Center at the bottom of left panel
  • Click on “Trust Center Settings” button on displayed pane
  • Choose “Protected View” from left panel
  • Uncheck all options on displayed pane, and click “OK” till back


Now when you open that file again, you will be able to do that, until any further issue, will keep that handy.

Empty a large list using powershell

Recently I wanted to delete all entries in a large list, but manually it was hectic and time consuming. One way could have been to delete and re-create that list, but that list was tightly bound to an InfoPath form, and I did not had any backup source available.

I had been experimenting in PowerShell these days, so looked around for any script which I could modify for my purpose.

Here is that script, took it from different sources mentioned here.

Continue reading

Deployment problems for sandbox solutions

I will list here different problems and their resolutions when we are trying to deploy sandbox solutions. That might help me quickly resolve these in future.

Problem 1: Error occurred in deployment step ‘Retract Solution’: Cannot start service SPUserCodeV4

I was working on a project which involved creating a simple Webpart and must be tested in sandbox environment, I tried to deploy it after some initial working, I got that message on deployment.

Where did that service is, I looked around and found that I need to start that service in Central Administration, as outlined below.

  1. Open Central Administration
  2. Click on “System Settings”
  3. Then click on “Manage services on this server”
  4. A list of services will be displayed, some of them will be stopped
  5. Look for “Microsoft SharePoint Foundation Sandboxed Code Service”
  6. Click on “start” on the last column, your services will be started shortly.

Now go back to your solution and try re-deploying.

How associations are mapped when using Code First with Entity Framework

Mapping single class with a table was bit easy and fun. Next should be mapping associations, first I will try to map a simple one, using our existing application code. A person can have multiple email addresses.

So here is the modified code for person

    public class PersonItem
        public int Id { get; set; }
        public string FirstName { get; set; }
        public string LastName { get; set; }
        public string Gender { get; set; }
        public Nullable<DateTime> BirthDate { get; set; }

        public virtual ICollection<EmailItem> Emails { get; set; }

        public PersonItem() { this.Emails = new List<EmailItem>(); }

Continue reading

Customizing schema generation when using Code First with Entity Framework

In my previous post I generated a database without any mapping or customization, I got what Entity Framework could coerce from my class. Look at the schema which was generated.

generated table schema

Let’s see what I did not like about this.

  • table name is not what I like to have
  • Id was not marked as identity column, so no auto generation for this column
  • all alphanumeric columns are created using nvarchar(MAX) which is not good too
  • and the last, I wanted to use only date for birthdate not datetime

Continue reading

Using code first with Entity Framework for generating database

I was working on a personal project today, and did a lot of experiments on Code First Model with Entity Framework. All of these were quite amazing and revealed a lot of underlying implementation and how things have progressed in Entity Framework world. I looked at various articles which helped me understand all these aspects, and am grateful of all of them. So I thought why not write some posts of mine too, just to document what I have learned, so that others might benefit from it too.

For that purpose I am starting with a simplest item, I will try to generate a database for a single class, and see how it looks. By the way I am using Entity Framework 5.

Here is the class, which I will work on.

Continue reading

using Func<T, TResult> for efficiently using DataReader

Today I was helping on a project which was using ADO.NET SQL Client. Wow, it looks so much scary, and old. I was asked to do some tweaks, so that data layer could be organized. Can I use Repository pattern here, one of the ways to add separation of responsibility these days.

So I started on creating a base class for these repositories. I thought of managing all connection related code in that base class. That was quite easy when I moved ExecuteNonQuery related calls here. Next came the hardest part ExecuteReader, how to send back DataReader without loosing control on my connection state. I can not move all reader related usage in base class, that would negate single responsibility rule.

Hmm, one way would be to create a virtual method in base class, and then each inherited class can override and implement it’s own mapping rules in it. I did small test with that, but soon was struck, what about mapping compositions. If I used this approach then I will have to add multiple conditional cases to map each item properly.

Then I thought of passing in mapper related methods as delegate, not bad. But why not use new concepts, Action<T, T …> / Func<T, …, TResult> / Predicate<T, …, bool>.

Continue reading