Home > Monkey Labs > Monkey Lab 01 – Postgres & ADO.Net Entity Framework

Monkey Lab 01 – Postgres & ADO.Net Entity Framework

November 16th, 2008

Getting started

You will need to download the following before you can continue.

If you have the Npgsql2.0RTM version then please download the latest version as there is bug in the RTM version.

I will assume that you already have a postgres 8.x Server at your disposal.
Instructions

  • Extract the Npgsql library to any location on your pc.
  • Locate and Open machine.config

C:\WINDOWS\Microsoft.NET\Framework\v2.0.50727\CONFIG\machine.config

  • Find the following element inside the config file <DbProviderFactories>
  • Add the following line below the <DbProviderFactories> tag.

<add name=”Npgsql Data Provider” invariant=”Npgsql” description=”.Net Framework Data Provider for PostgreSQL Server” type=”Npgsql.NpgsqlFactory, Npgsql, Version=2.0.1.0, Culture=neutral, PublicKeyToken=5d8b90d52f46fda7″/>

  • Locate and Open the Assembly Explorer (GAC), keep this window open.

C:\WINDOWS\assembly

  • Open up the directory to where your Npgsql.dll is stored.
  • Now drag-n-drop both the Npgsql.dll and the Mono.Security.dll into the assembly window.

You could’ve also used gacutil -I “C:\[PathToNpgsqlBinDirectory]\Npgsql.dll”

And thats it! You have now successfully prepared your development environment for working with the Entity Framework and postgres Npgsql. In the next monkey lab I’ll show you how to create .edmx files from your postgres schema’s.

Monkey Labs , , , ,

  1. Andrew Basson
    November 21st, 2008 at 20:45 | #1

    Hi Zaheer,

    I think you need to add Mono to the gacutil part too :)

    Thanks for putting this online.

    Cheers, Andrew.

  2. November 30th, 2008 at 16:02 | #2

    Nice post u have here :D Added to my RSS reader

  3. MB
    April 7th, 2009 at 16:37 | #3

    When is part 2 coming out?

  4. MB
    April 7th, 2009 at 16:55 | #4

    On another note, when I add the key to the web.config and open up VS is says Configuration failed to initilise and when I go into Create new connection, nothing is available in the data providers drop down list?

    cheers

  5. Zaheer
    April 7th, 2009 at 22:50 | #5

    @MB: Comment #3 – I would like to get part 2 of this tutorial out by april, i just havent had the time available to update this site as regularly as i would’ve like to.

    Comment #4 – This is correct due to the Npgsql’s lack of VS integration it wont be available as a selectable data provider within VS. Lets hope that the guys at pgfoundry are working hard on this one for the next major release.

  6. May 8th, 2009 at 13:07 | #6

    Hello Zaheer.

    So how would one create the .emdx model and entity mapping without first creating a data source in the Server Explorer? I found creating a Npgsql data source impossible due due to the lacking VS integration support (DDEX).

    I’ve also tried to create a data source using the OLE DB provider, but it failed with this error message: “Multiple-step OLE DB operation generated errors. Check each OLE DB status value, if available. No work was done.” (Note that connection test was successful). Has anyone experienced and/or solved this problem? I don’t understand it because using the Postgre OLE DB provider directly from code seems to work fine.

    Finally I only managed to create a Postgre data source using ODBC provider. But that’s an unnecessary thick layer and does not seem to work with entity framework either.

    So my question is: am I just failing to create a postgre data source (and how to go about that) or is there a way to create the entity model and mapping without an actual data source in the Server Explorer?

    Sorry if my questions sound lame, but I’m quite new to data programming in .Net and I was unable to resolve this using google :)

    Thanks.

  1. No trackbacks yet.