<docbook><section><title>VirtEntityFrameworkDB2DatService</title><bridgehead class="http://www.w3.org/1999/xhtml:h3">Creating an ADO.Net Data Service</bridgehead>
<para>An ADO.Net Data Service for the DB2 tables can be created using the Entity Data Model created in the <ulink url="VirtDB2EDM">Creating EDM in Visual Studio 2008</ulink> section.</para><para>1.
 Open the <emphasis>VirtuosoDataService</emphasis> project created in the <ulink url="VirtDB2EDM">Creating EDM in Visual Studio 2008</ulink> section.</para><para>2.
 Right click on the <emphasis>VirtuosoDataService</emphasis> project name in the <emphasis>Solution Explorer</emphasis> pane.
 Then, select the <emphasis>Add</emphasis> -&gt; <emphasis>New Item</emphasis> menu options.
<figure><graphic fileref="VirtEntityFrameworkDB2DatService/VirtAdoNetDataServices_4.png" /></figure></para><para>3.
 The <emphasis>Add New Item</emphasis> dialog will appear.
 Choose the <emphasis>ADO.NET Data Service</emphasis> template.
 Give it the name <emphasis>Virtuoso.svc</emphasis>, and click <emphasis>Add</emphasis> to create the ADO.Net Data Service.
<figure><graphic fileref="VirtEntityFrameworkDB2DatService/VirtAdoNetDataServices_15.png" /></figure></para><para>4.
 In the newly created <emphasis>Virtuoso.svc.cs</emphasis> Data Service file, add the data source class name of <emphasis>VirtuosoEntities</emphasis> (note this is the name set in the Creating EDM in Visual Studio 2008 section) as the <emphasis>DataService</emphasis> name.
 Enable access to the Data Service by adding the entry <emphasis>config.SetEntitySetAccessRule(&quot;*&quot;, EntitySetRights.All);</emphasis> to the <emphasis>InitializeService</emphasis> method.</para><programlisting>
// C#

using System;
using System.Web;
using System.Collections.Generic;
using System.ServiceModel.Web;
using System.Linq;
using System.Data.Services;

namespace SimpleDataService
{
    public class Northwind : DataService&lt;VirtuosoDemoEntities&gt;
    {
        public static void InitializeService(IDataServiceConfiguration  config)
        {
            config.SetEntitySetAccessRule(&quot;*&quot;, EntitySetRights.All);
        }
    }
}

</programlisting><figure><graphic fileref="VirtEntityFrameworkDB2DatService/VirtAdoNetDataServices_16.png" /></figure>
<para>5.
 To test the Data Service, simply hit <emphasis>Ctrl+F5</emphasis> within Visual Studio.
 This will start the development web server, run the Data Services server inside, and load a Web browser page displaying the list of tables/entities for the Sample database catalog.
<figure><graphic fileref="VirtEntityFrameworkDB2DatService/EntityFrameworksDB2DataService1.png" /></figure></para><para>6.
 To access a specific entity instance like the EMPLOYEES table employee number &quot;000010&quot; record, use this convention <emphasis><ulink url="http://host/vdir/Virtuoso.svc/EMPLOYEES(">http://host/vdir/Virtuoso.svc/EMPLOYEES(</ulink>&quot;000010&quot;)</emphasis>.
<figure><graphic fileref="VirtEntityFrameworkDB2DatService/EntityFrameworksDB2DataService2.png" /></figure></para><para> </para><bridgehead class="http://www.w3.org/1999/xhtml:h3">NOTES</bridgehead>
<para>1.
 <emphasis>Important</emphasis> - To view <emphasis>Atom</emphasis> (the default format returned by an ADO.NET Data Service) in Internet Explorer, you must first ensure that <emphasis>Feed Reading View</emphasis> is turned <emphasis>off</emphasis>.
 This can be done on the <emphasis>Content tab</emphasis> of <emphasis>Tools<emphasis> in <emphasis>Internet Options</emphasis>.</emphasis></emphasis></para><para>2.
 If a Data Services entity instance URI page fails to load, you can turn <emphasis>Verbose</emphasis> errors on by adding <emphasis>config.UseVerboseErrors <computeroutput>=</computeroutput> true;</emphasis> in the <emphasis>virtuoso.svc.cs InitializeService </emphasis> method.
 This enables you to obtain more detailed information from the server as to why the page failed to load:</para><programlisting>
public static void InitializeService(IDataServiceConfiguration config)

{

config.UseVerboseErrors = true;

config.SetEntitySetAccessRule(&quot;*&quot;, EntitySetRights.All);

}

</programlisting></section></docbook>