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.



    24 comments:

    1. How do i copy and paste to gac (c:\windows\assembly) ???

      The folder gac ain't visable and you can't copy or paste into or from it.

      ReplyDelete
    2. Just paste it inside the folder "C:\windows\assembly". This folder IS your GAC (Global assembly cache) and windows explorer recognizes it as such :)

      Safely ignore what I am about to say below. The above is what you need to do.

      if you do "cd c:\windows\assembly" in cmd and then "dir" you will see the gac folders (yes plural).. but you never need to use those folders. Windows explorer does not show them and puts your assembly in the appropriate GAC folder :)

      ReplyDelete
    3. Just FYI:
      http://blogs.msdn.com/b/cumgranosalis/archive/2005/10/03/476275.aspx

      ReplyDelete
    4. Hello Basarat,
      is your example only for FB Server 2.5.X ??

      In FB 2.1.3 i have an error 75 in the keys.

      In Server 2.5. RC2 it works.

      Winfried

      ReplyDelete
    5. @winfried
      Yes afraid so.
      Plus:
      I moved to nhibernate rather than ado.net entity framework.

      ReplyDelete
    6. yep dosen't work for me

      ReplyDelete
    7. carefully I follow these steps, but when I type a character in Add Connection dialog, the dialog disappear. what's the possible cause?

      I'm using win7 home premium and VS 2010 Ultimate

      tq

      ReplyDelete
    8. >> Just go to visual studio server explorer window and add a new connection to Firebird.

      But this explorer only for LINQ2SQL, not for EF!
      How add firebird to list providers of ef?
      I have same picture as there http://stackoverflow.com/questions/1412086/how-to-register-firebird-data-provider-for-entity-framework

      Windows 7 x64. Visual Studio 2008/2010
      I confugured both to have linq2sql support, but not ef for firebird

      ReplyDelete
    9. carefully I follow these steps, but when I type a character in Add Connection dialog, the dialog disappear. what's the possible cause?

      I'm using win7 home premium and VS 2010 Ultimate

      i have same problem, how can i solve this problem ?

      ReplyDelete
    10. the cause is that you have used the wrong assembly details in machine.config

      you need to use the details for

      FirebirdSql.Data.FirebirdClient

      not

      FirebirdSql.VisualStudio.DataTools

      FirebirdSql.Data.FirebirdClient comes from the FirebirdClient.msi installer, but you need to manually add it to the GAC.

      sam-english at hotmail dot com if you want more help on this issue

      ReplyDelete
    11. gracias, estube buscando como hacer esto por mucho tiempo... =)

      ReplyDelete
    12. I have to enter in regedit manualy to add the CodeBase path. It WORKS, thank you.

      ReplyDelete
    13. Hi Basarat,

      Thanks for the article. Very informative. I don't really care too much about the tools on VS environment, I just would like to add a reference to the FirebirdSql.Data.FirebirdClient.dll. But as soon as I do that, there is a yellow warning icon sign on my reference. And in my Errors List (as a Warning), I have the following:

      The referenced component 'FirebirdSql.Data.FirebirdClient' could not be found.

      Please check the screen shot:
      http://bit.ly/mmAB9L

      Thanks for your help.

      ReplyDelete
    14. @fabrizio just copy the dll to some folder other than GAC and then try adding a reference to it. PS: I cannot open your url : http://bit.ly/mmAB9L
      you should send the non bit.ly link since imageshack does not allow this particular url redirection.

      ReplyDelete
    15. Hi Basarat,

      Thanks for the quick response! Much appreciated.
      So, I have copied the DLL to a few different folders. Initially after installing the Firebird Client, it was in \Program Files\FirebirdClient. Then I've copied the DLL around. No joy.
      Also, I cannot copy the DLL to GAC. Not even drag-and-drop works.
      So here is the screenshot without the bitly shortener.

      http://img856.imageshack.us/img856/1169/screenshotrod.jpg

      Thank you!

      ReplyDelete
    16. @fabrizio I can't see your image even now :( PS: if you can't add it to the gac maybe the dll is corrupt. Try downloading it again.

      ReplyDelete
    17. I've downloaded it 3 times already. The zip file and the MSI. The DLL is ok but when I add the reference to it, it just does not work on VS. :(

      Thanks, Basarat

      ReplyDelete
    18. As said by someone here before, dont past the CodeBase path in .reg file. It only works if you enter it manually via regedit.exe. Don't know why, tho..

      ReplyDelete
    19. Excellent guidance. I had the dialog disappearing issue mentioned by others after following similar guidance elsewhere. I found that after registering the client in the GAC and using the correct version and publickeytoken all is working with Ver 2.6.5 and VS 2010.

      Many thanks Basarat.

      ReplyDelete
    20. I have win7 x64 and I had some troubles adding the dll to the gac.
      This works for me:
      Download the windows 7 SDK (framework 4) and install only the .net development tools.
      Go to start-> all programs -> Microsoft windows SDK -> and run the windows SDK prompt as an administrator.
      Then go to the folder
      c:\program files\microsoft SDKs\Windows\v7.1\Bin\NETFX 4.0 Tools\x64
      and run here
      gacutil /i "C:\program files (x86)\FirebirdClient\FirebirdSql.Data.FirebirdClient.dll"

      ReplyDelete
    21. how do you get the PublicKeyToken number?
      somehow the gacutil tool should provide it but how?

      ReplyDelete
    22. Hey Basarat,

      Just curious, how would I set this up to work in VS2010 with both framework 3.5 and framework 4.0? I got it working with 4.0.

      Do I have to install 2 versions of the assemply?

      ReplyDelete
    23. Basarat

      I haven't used it, but Kellerman Software has a LINQ provider for Firebird
      https://www.kellermansoftware.com/p-47-net-data-access-layer.aspx

      ReplyDelete