Can't get XSD to generate DataSet primary keys - CSharp

This is a discussion on Can't get XSD to generate DataSet primary keys - CSharp ; [.Net 2.0, VS2005 SP1, MSDataSetGenerator used through IDE] No matter how I shape my XSD, I can't get it to create primary keys in my data set. I have looked at tons of examples, followed them to the letter, but ...

+ Reply to Thread
Results 1 to 2 of 2

Can't get XSD to generate DataSet primary keys

  1. Default Can't get XSD to generate DataSet primary keys

    [.Net 2.0, VS2005 SP1, MSDataSetGenerator used through IDE]

    No matter how I shape my XSD, I can't get it to create primary keys in my
    data set. I have looked at tons of examples, followed them to the letter,
    but still no go. When I merge my data sets I get duplicate records. If I go
    in and add the PrimaryKey to the DataSet based classes that were generated
    by the tool everything works. I just can't get the tool to create them. Help
    Please.

    (One thing I did notice that was weird was that in VisualStudio intellisense
    was available for msdata:whatever, all the attributes I saw in the examples
    were available except msdata:PrimaryKey).

    Anyway here is my XSD

    <?xml version="1.0" encoding="UTF-8"?>

    <xs:schema xmlns:xs="http://www.w3.org/2001/XMLSchema"
    xmlns:msdata="urn:schemas-microsoft-com:xml-msdata" id="SensorDataSet">

    <xs:element name="Type" type="xs:string" />

    <xs:element name="Timestamp" type="xs:string" />

    <xs:element name="Start" type="xs:decimal" />

    <xs:element name="Speed" type="xs:byte" />

    <xs:element name="OrderNumber" type="xs:short" />

    <xs:element name="NameDescription" type="xs:string" />

    <xs:element name="Name" type="xs:string" />

    <xs:element name="Longitude" type="xs:decimal" />

    <xs:element name="Latitude" type="xs:decimal" />

    <xs:element name="ItsRoadwayDescription" type="xs:string" />

    <xs:element name="Id" type="xs:string" />

    <xs:element name="Description" type="xs:string" />

    <xs:element name="Sensor">

    <xs:complexType>

    <xs:sequence>

    <xs:element ref="Type" />

    <xs:element ref="OrderNumber" />

    <xs:element ref="Id" />

    <xs:element ref="Description" />

    <xs:element ref="ItsRoadwayDescription" />

    <xs:element ref="Latitude" />

    <xs:element ref="Longitude" />

    <xs:element ref="Speed" />

    <xs:element ref="RouteId" />

    </xs:sequence>

    </xs:complexType>

    </xs:element>

    <xs:element name="RouteId" type="xs:string" />

    <xs:element name="Route">

    <xs:complexType>

    <xs:sequence>

    <xs:element ref="Id" />

    <xs:element ref="Name" />

    <xs:element ref="Description" />

    <xs:element ref="NameDescription" />

    <xs:element ref="Start" />

    </xs:sequence>

    </xs:complexType>

    </xs:element>

    <xs:element name="SensorFeed">

    <xs:complexType>

    <xs:sequence>

    <xs:element ref="Sensor" maxOccurs="unbounded" />

    <xs:element ref="Route" maxOccurs="unbounded" />

    <xs:element ref="Timestamp" minOccurs="1"
    maxOccurs="1" />

    </xs:sequence>

    </xs:complexType>

    <xs:key name="SensorPrimaryKey" msdata:PrimaryKey="true"
    msdata:ConstraintName="SensorPrimaryKey">

    <xs:selector xpath=".//Sensor" />

    <xs:field xpath="Id" />

    </xs:key>

    <xs:key name="RoutePrimaryKey" msdata:PrimaryKey="true"
    msdata:ConstraintName="RoutePrimaryKey">

    <xs:selector xpath=".//Route" />

    <xs:field xpath="Id" />

    </xs:key>

    <xs:keyref name="SensorRouteForeignKey" refer="RoutePrimaryKey">

    <xs:selector xpath=".//Sensor" />

    <xs:field xpath="RouteId" />

    </xs:keyref>

    </xs:element>

    </xs:schema>



    Thanks
    --
    Howard Swope [hswope.swopeATnavteqDOTcom]
    Senior Software Developer
    Media Development
    Navteq Traffic [http://www.traffic.com]



  2. Default Re: Can't get XSD to generate DataSet primary keys

    I just got fed up and simplified the .xsd as much as possible, I inlined all
    the refs, and then it generated the primary keys. Yeah...

    "Howard Swope" <hswopeATtrafficDOTcom> wrote in message
    news:%23Gqn7pGKIHA.3672@TK2MSFTNGP02.phx.gbl...
    > [.Net 2.0, VS2005 SP1, MSDataSetGenerator used through IDE]
    >
    > No matter how I shape my XSD, I can't get it to create primary keys in my
    > data set. I have looked at tons of examples, followed them to the letter,
    > but still no go. When I merge my data sets I get duplicate records. If I
    > go in and add the PrimaryKey to the DataSet based classes that were
    > generated by the tool everything works. I just can't get the tool to
    > create them. Help Please.
    >
    > (One thing I did notice that was weird was that in VisualStudio
    > intellisense was available for msdata:whatever, all the attributes I saw
    > in the examples were available except msdata:PrimaryKey).
    >
    > Anyway here is my XSD
    >
    > <?xml version="1.0" encoding="UTF-8"?>
    >
    > <xs:schema xmlns:xs="http://www.w3.org/2001/XMLSchema"
    > xmlns:msdata="urn:schemas-microsoft-com:xml-msdata" id="SensorDataSet">
    >
    > <xs:element name="Type" type="xs:string" />
    >
    > <xs:element name="Timestamp" type="xs:string" />
    >
    > <xs:element name="Start" type="xs:decimal" />
    >
    > <xs:element name="Speed" type="xs:byte" />
    >
    > <xs:element name="OrderNumber" type="xs:short" />
    >
    > <xs:element name="NameDescription" type="xs:string" />
    >
    > <xs:element name="Name" type="xs:string" />
    >
    > <xs:element name="Longitude" type="xs:decimal" />
    >
    > <xs:element name="Latitude" type="xs:decimal" />
    >
    > <xs:element name="ItsRoadwayDescription" type="xs:string" />
    >
    > <xs:element name="Id" type="xs:string" />
    >
    > <xs:element name="Description" type="xs:string" />
    >
    > <xs:element name="Sensor">
    >
    > <xs:complexType>
    >
    > <xs:sequence>
    >
    > <xs:element ref="Type" />
    >
    > <xs:element ref="OrderNumber" />
    >
    > <xs:element ref="Id" />
    >
    > <xs:element ref="Description" />
    >
    > <xs:element ref="ItsRoadwayDescription" />
    >
    > <xs:element ref="Latitude" />
    >
    > <xs:element ref="Longitude" />
    >
    > <xs:element ref="Speed" />
    >
    > <xs:element ref="RouteId" />
    >
    > </xs:sequence>
    >
    > </xs:complexType>
    >
    > </xs:element>
    >
    > <xs:element name="RouteId" type="xs:string" />
    >
    > <xs:element name="Route">
    >
    > <xs:complexType>
    >
    > <xs:sequence>
    >
    > <xs:element ref="Id" />
    >
    > <xs:element ref="Name" />
    >
    > <xs:element ref="Description" />
    >
    > <xs:element ref="NameDescription" />
    >
    > <xs:element ref="Start" />
    >
    > </xs:sequence>
    >
    > </xs:complexType>
    >
    > </xs:element>
    >
    > <xs:element name="SensorFeed">
    >
    > <xs:complexType>
    >
    > <xs:sequence>
    >
    > <xs:element ref="Sensor" maxOccurs="unbounded" />
    >
    > <xs:element ref="Route" maxOccurs="unbounded" />
    >
    > <xs:element ref="Timestamp" minOccurs="1"
    > maxOccurs="1" />
    >
    > </xs:sequence>
    >
    > </xs:complexType>
    >
    > <xs:key name="SensorPrimaryKey" msdata:PrimaryKey="true"
    > msdata:ConstraintName="SensorPrimaryKey">
    >
    > <xs:selector xpath=".//Sensor" />
    >
    > <xs:field xpath="Id" />
    >
    > </xs:key>
    >
    > <xs:key name="RoutePrimaryKey" msdata:PrimaryKey="true"
    > msdata:ConstraintName="RoutePrimaryKey">
    >
    > <xs:selector xpath=".//Route" />
    >
    > <xs:field xpath="Id" />
    >
    > </xs:key>
    >
    > <xs:keyref name="SensorRouteForeignKey"
    > refer="RoutePrimaryKey">
    >
    > <xs:selector xpath=".//Sensor" />
    >
    > <xs:field xpath="RouteId" />
    >
    > </xs:keyref>
    >
    > </xs:element>
    >
    > </xs:schema>
    >
    >
    >
    > Thanks
    > --
    > Howard Swope [hswope.swopeATnavteqDOTcom]
    > Senior Software Developer
    > Media Development
    > Navteq Traffic [http://www.traffic.com]
    >




+ Reply to Thread

Similar Threads

  1. Primary Keys
    By Application Development in forum ADO DAO RDO RDS
    Replies: 4
    Last Post: 10-11-2007, 05:28 PM
  2. How does VS2005 generate the dataset class when dataset is created
    By Application Development in forum ADO DAO RDO RDS
    Replies: 0
    Last Post: 08-16-2007, 07:53 PM
  3. EJB 2.0: Compount Primary Keys and CMR
    By Application Development in forum Java
    Replies: 1
    Last Post: 03-01-2007, 09:39 AM
  4. Hibername mapping: Specifying primary keys.
    By Application Development in forum Java
    Replies: 1
    Last Post: 08-05-2005, 01:20 PM
  5. CRecordSet and Primary Keys
    By Application Development in forum ADO DAO RDO RDS
    Replies: 0
    Last Post: 07-29-2004, 08:54 AM