Make The Visual Studio Extensions Compatible With Visual Studio 11 Developer Preview

Do you use Visual Studio 11 Developer Preview and miss your extensions? Well, I do! Especially, ADO.NET C# DbContext Generator. We'll see how to make them compatible with Visual Studio 11 Dev. Preview
7 December 2011
3 minutes read

Related Posts

works-on-my-machine-seal-of-approvalDo you use Visual Studio 11 Developer Preview and miss your extensions? Well, I do! Especially, ADO.NET C# DbContext Generator.

As you know, for now Visual Studio extensions are not compatible with Visual Studio 11 Developer Preview.

image

This is normal because it is Developer Preview. Even, I opened up a thread for that on Stackoverflow: Visual Studio Extensions and Visual Studio 11 Dev. Preview and @betty replied to my post after a long time with an amazing answer. I never developed a Visual Studio extension before and I am not familiar with the drill so I thought it is not possible to tweak the extensions so that they can be compatible with Visual Studio 11 Developer Preview but it turns out that it is as easy as pie. How so? Here are the steps:

Oww, by the way, this thing works on my machine and I am not guarantee that it will work on yours as well. Even worse, it can completely screw your machine up. So, take the risk here and don’t swear to me.

I also assume that the ADO.NET C# DbContext Generator does not integrate with Visual Studio that much so there was no big compatibility problems but I won’t try this for the extensions like VSCommands 2010, Web Essentials, etc. If you try, please let me know how it went. Anyway, here is the drill:

First of all, download the extension from Visual Studio Gallery.

image

I am not sure if you are aware of it but vsix files are actually zip files just like NuGet package files (nupkg) and MS Word files (docx). So, change the extension of the file we have downloaded from vsix to zip:

image image

Unzip the zip file and you will see a file called extension.vsixmanifest under root folder. No, it is not a zip file, too Open-mouthed smile It is an xml file though. Open it up with a text editor and find the node called SupportedProducts:

image

Just change the value of version attribute of VisualStudio node to 11.0 and save it.

image

This is actually enough for the extension compatibility standpoint but ADO.NET C# DbContext Generator extension has some dependencies which are specific to Visual Studio 2010 (not sure on that though). So,we have one more step to go as well.

Navigate to /T/code/ folder and you will see a zip file there:

image

Unzip it:

image

Open up the file called ADONETArtifactGenerator_DbContextCSharp.vstemplate with a text editor this time and you will notice a node like below:

  <WizardExtension>
    <Assembly>Microsoft.Data.Entity.Design, Version=10.0.0.0, Culture=neutral, PublicKeyToken=b03f5f7f11d50a3a</Assembly>
    <FullClassName>Microsoft.Data.Entity.Design.VisualStudio.ModelWizard.AddArtifactGeneratorWizard</FullClassName>
  </WizardExtension>

Change this one with the below code:

  <WizardExtension>
    <Assembly>Microsoft.Data.Entity.Design, Version=11.0.0.0, Culture=neutral, PublicKeyToken=b03f5f7f11d50a3a</Assembly>
    <FullClassName>Microsoft.Data.Entity.Design.VisualStudio.ModelWizard.AddArtifactGeneratorWizard</FullClassName>
  </WizardExtension>

Don’t ask me why because I have no clue. I assumed that it was a versioning issue and it works this way. Remember, this is developer preview. Not even alpha or beta so don’t look for logic that much.

Save the file and zip it up again.

image,

Don’t forget to delete other files. You just need that zip file inside the code folder.

Lastly, go under the root and zip all the files:

image

image

Now we have a zip file again. Change the extension from zip to vsix and double click on that

imageimage

Now we get it working smoothly:

imageimage

Now when you want to continue you way with database first approach, you can follow the steps which are explained here:

http://blogs.msdn.com/b/adonet/archive/2011/11/01/ef-4-2-released.aspx

Here is the quote from that blog post:

Model First & Database First Templates

The templates for using the DbContext API with Model First and Database First are now available under the “Online Templates” tab when “Right-Click –> Add Code Generation Item…” is selected on the EF Designer.

Instead of navigating to "Online Templates" tab, you will find the code gen. file under the "Code" tab:

image

Admit it, we totally nailed that thing Winking smile