Saturday, February 27, 2010

Setting up firebird development with VS 2008 / VS 2010 with ADO.NET Entity Framework designer support

Here is how to integrate firebird in VS 2008. Tested now with VS 2010 as well.

From
http://www.firebirdsql.org/index.php?op=files&id=netprovider

Download the following:

  1. Zip DDEX
  2. Zip FirebirdClient
Now do the following:
 
  • Extract zip file 2 (FirebirdClient) and copy paste the file "FirebirdSql.Data.FirebirdClient" to GAC (c:\windows\assembly) 
  • Right click the item in "FirebirdSql.Data.FirebirdClient" in c:\windows\assembly and copy the version, culture and public key token. For my version of the dll 2.5.2.0 , culture = neutral, Public key token "3750abcc3150b00c"
  • Modify the machine.config (only edit the 32 bit file since vs.net is 32 bit) file at "C:\Windows\Microsoft.NET\Framework\v2.0.50727\CONFIG" adding the lines as given in readme.txt from zip file 1 (DDEX) . However I only added the DbProviderFactories and not the configSections. The following is what I added: 
add name="FirebirdClient Data Provider" invariant="FirebirdSql.Data.FirebirdClient" description=".Net Framework Data Provider for Firebird" type="FirebirdSql.Data.FirebirdClient.FirebirdClientFactory, FirebirdSql.Data.FirebirdClient, Version=2.5.2.0, Culture=neutral, PublicKeyToken=3750abcc3150b00c"

PS: For visual studio 2010 I also needed to add the same to the machine.config in the following folder: "C:\Windows\Microsoft.NET\Framework\v4.0.30319\Config" Since it runs on .NET 4.0 runtime. Otherwise you will get an error as mentioned in the errors section below.

  •  Take the two DLL files in the zip file 1 (DDEX) and place them at : "C:\Program Files (x86)\Microsoft Visual Studio 9.0\Common7\IDE" Modify this as per you installation of VS.  (for VS 2010 : C:\Program Files (x86)\Microsoft Visual Studio 10.0\Common7\IDE )
  • In zip file 1 (DDEX) edit the reg file for you system (32 bit or 64 bit) setting %path% to the location of the dll file in the previous step. e.g. in our case : "CodeBase"="C:\\Program Files (x86)\\Microsoft Visual Studio 9.0\\Common7\\IDE\\FirebirdSql.VisualStudio.DataTools.dll"  (again as per your VS version). Merge the reg file. (My windows was 64 Bit and I only added the VS 2010 FirebirdDDEXProvider64.reg file)

Now you can play with Firebird using VS 2008  / VS 2010 to your heart's content!
Just go to visual studio server explorer window and add a new connection to Firebird.

Errors:
  • When you add a new connection from Visual Studio's server explorer, a customized Firebird Data tools dialog should open. If all you see is a Connection String option double check your Reg file since visual studio did not get the DataTools dlls. You will also probably get the following error :
  • Error: "Failure has occurred while loading a type" it means that the .reg file contained some error. In my case the CodeBase path was incorrect.
  • If you type anything in any field in the new connection dialog, the dialog box closes. If you click OK you get the following error: "Unable to find the requested .NET Framework Data Provider. It may not be installed". This occurs when you have invalid / missing configuration in machine.config. Remember that VS 2010 needs you to update machine.config in V4 folder and VS 2008 needs you to update in V2 of the runtime. (mentioned above)

Here are some additional firebird notes:
Default Username / Password
Given in the quickstart in the docs folder. Mine was "SYSDBA" with password "masterkey" 
Define Aliases / Databases
modified aliases.conf in your installation directory to add the following line :
employee = F:\FIREBIRD\examples\empbuild\EMPLOYEE.FDB

not required but useful
VS Connection Dialog
Datasource = 127.0.0.1
Port = 3050
Database = employee
User=SYSDBA
Password=masterkey
And I changed nothing more. Test connection and it works.