<docbook><section><title>VirtInformixEntityFrameworkUsage</title><title> Using Microsoft Entity Frameworks to Access Informix Schema Objects with Virtuoso</title> Using Microsoft Entity Frameworks to Access Informix Schema Objects with Virtuoso
<para>This document details the steps required to provide Microsoft Entity Framework access to Informix Schema Objects using the OpenLink Virtuoso Universal Server.
 This is achieved by linking the required Informix Schema objects into Virtuoso using its built-in Virtual Database engine and then using the Virtuoso ADO.NET Entity Framework provider to query the remote Informix Schema objects linked into the Virtuoso Server.</para><bridgehead class="http://www.w3.org/1999/xhtml:h2">Prerequisites</bridgehead>
<para>The following prerequisites must be in place for this solution to be possible.</para><bridgehead class="http://www.w3.org/1999/xhtml:h3"> Informix DBMS</bridgehead>
<para>An Informix DBMS hosting the required Schema Objects needs to be available.
 In this document the <emphasis>Informix stores_demo</emphasis> sample database will be used to demonstrate the process.</para><bridgehead class="http://www.w3.org/1999/xhtml:h3"> ODBC Driver for Informix</bridgehead>
<para>An Informix ODBC Driver is required for Linking the Informix Schema Objects into the Virtuoso Server.
 The <emphasis>OpenLink ODBC Driver for Informix</emphasis> will be used in this document, for which a functional ODBC Data source name of <emphasis>inf10ma</emphasis> will be assumed to exist on the machine hosting the Virtuoso Server.</para><bridgehead class="http://www.w3.org/1999/xhtml:h3"> Virtuoso Universal Server </bridgehead>
<para>An Virtuoso installation including the Virtuoso Universal Server and ADO.NET Entity Framework Provider is required.
 The Virtuoso components used must be Release 5.10.x or above, this being the minimum version containing support for Microsoft Entity Frameworks.</para><bridgehead class="http://www.w3.org/1999/xhtml:h3"> Microsoft Visual Studio 2008 SP1 (or later)</bridgehead>
<para>At minimum, Microsoft Visual Studio 2008 Service Pack 1 is required.
 Later versions of Visual Studio may require some extra steps, e.g., <ulink url="http://virtuoso.openlinksw.com/dataspace/doc/dav/wiki/Main/VirtTipsAndTricksEnableAdoNetProviderInVS2010">VS2010</ulink>.</para><bridgehead class="http://www.w3.org/1999/xhtml:h2"> Tasks</bridgehead>
<bridgehead class="http://www.w3.org/1999/xhtml:h3"> Ensure Informix Primary Keys (PKs) are not nullable  </bridgehead>
<para>The Visual Studio 2008 Entity Data Model (EDM) requires that all primary keys are  <emphasis>NOT</emphasis> Nullable, and will fail to generate an EDM if any are.
 Thus ensure any tables to be used are defined as not nullable in the Informix database schema before attempting to generate an EDM.
 In the case of the Informix stores_demo database many tables have primary keys that are <emphasis>are</emphasis> nullable, so these will need to be redeclared.</para><para>This is possible using <emphasis>dbaccess</emphasis>.
 However, care needs to be taken, particularly with the following -</para><itemizedlist mark="bullet" spacing="compact"><listitem> Amending a PK field to be not nullable can result in the primary key constraint being removed.</listitem>
</itemizedlist><itemizedlist mark="bullet" spacing="compact"><listitem> Amending a PK field to be not nullable--when the primary key is referenced by a foreign key constraint--results in the foreign key constraint being removed.</listitem>
</itemizedlist><para>In both of the cases above, the primary key and foreign key constraints that are removed will have to be manually recreated.</para><para> </para><bridgehead class="http://www.w3.org/1999/xhtml:h3"> Install and configure ODBC Driver for Informix</bridgehead>
<para>The Virtuoso Virtual Database engine uses ODBC as the connectivity mechanism for linking remote database objects into its local schema.
 Thus, an Informix ODBC Driver must be available with a suitably configured DSN for connecting to the target database.
 The OpenLink ODBC Drivers for Informix have been used in this document, although in theory any Informix ODBC Driver can be used.</para><para>Installation instructions for the OpenLink ODBC Driver for Informix are available from:</para><itemizedlist mark="bullet" spacing="compact"><listitem> <ulink url="http://wikis.openlinksw.com/dataspace/owiki/wiki/UdaWikiWeb/InstallConfigODBC">Product Installation &amp; Basic Configuration (ODBC)</ulink></listitem>
</itemizedlist><bridgehead class="http://www.w3.org/1999/xhtml:h3"> Install and configure Virtuoso Universal Server</bridgehead>
<itemizedlist mark="bullet" spacing="compact"><listitem> <ulink url="VirtADOClientServInstall">Install and configure OpenLink Virtuoso Universal Server</ulink></listitem>
</itemizedlist><bridgehead class="http://www.w3.org/1999/xhtml:h3"> Link Informix tables into Virtuoso</bridgehead>
<itemizedlist mark="bullet" spacing="compact"><listitem> <ulink url="VirtINFLinkingObjects">Linking Informix tables into OpenLink Virtuoso</ulink></listitem>
</itemizedlist><bridgehead class="http://www.w3.org/1999/xhtml:h3"> Create a Visual Studio hosted Entity Data Model (EDM)</bridgehead>
<itemizedlist mark="bullet" spacing="compact"><listitem> <ulink url="VirtINFEDM">Creating an EDM in Visual Studio 2008</ulink></listitem>
</itemizedlist><bridgehead class="http://www.w3.org/1999/xhtml:h3"> Use EDM to create Entity Framework based applications</bridgehead>
<para>Now that a Microsoft Entity Data Model has been created for the Informix stores_demo database, Entity Framework applications can be created to make use of it.</para><bridgehead class="http://www.w3.org/1999/xhtml:h4"> Entity Frameworks based ADO.NET Data Service</bridgehead>
<itemizedlist mark="bullet" spacing="compact"><listitem> <ulink url="VirtEntityFrameworkINFDatService">Entity Framework Data Service</ulink></listitem>
</itemizedlist><bridgehead class="http://www.w3.org/1999/xhtml:h4"> Visual Studio Windows Form Application</bridgehead>
<itemizedlist mark="bullet" spacing="compact"><listitem> <ulink url="VirtInformixVisualStudioDataGridFormsApp">Windows DataGrid Form Application</ulink></listitem>
</itemizedlist><para> </para></section></docbook>