I have the same issue as this question (exactly the same need): How can I declare a Clustered key on a many-to-many relationship table in CodeFluent Entities with Sql Server Producer
I tried to use the aspect but I am not sure how I should set up the configuration.
Should I add cfps:hint="CLUSTERED"
for both of my tables ? I tried but I still get the same error
SQL80001: Incorrect syntax near 'CLUSTERED'.
Or maybe my aspect is not correctly set up. (It's the first time I use an aspect).
Maybe a good things to include in the product itself.
=> Update => I still have the same issue. Key is not clustered on the relation table.. It's not exactly the same kind of relation.
Here is my model (extract) :
<cf:entity name="Hotel" namespace="Marmara">
<cf:property name="ProductCode" cfps:hint="CLUSTERED" key="true" typeName="string" />
<cf:property name="Hotels" typeName="Marmara.BookingCollection" />
<cf:property name="Name" />
<cf:property name="Rating" typeName="decimal" />
</cf:entity>
<cf:entity name="Fly" namespace="Marmara">
<cf:property name="TakeOffDate" cfps:hint="CLUSTERED" key="true" typeName="date" />
<cf:property name="Bookings" typeName="Marmara.BookingCollection" />
</cf:entity>
<cf:entity name="Booking" setType="List" trackingModes="None" namespace="Marmara">
<cf:property name="Hotel" key="true" typeName="Marmara.Hotel" />
<cf:property name="Fly" key="true" typeName="Marmara.Fly" />
<cf:property name="Price" typeName="int" />
<cf:property name="AvailableSeat" typeName="int" />
<cf:property name="RunTimeDate" key="true" typeName="Marmara.RunTimeDate" />
</cf:entity>
<cf:entity name="RunTimeDate" namespace="Marmara">
<cf:property name="Date" cfps:hint="CLUSTERED" key="true" typeName="datetime" />
<cf:property name="RunTimeDates" typeName="Marmara.BookingCollection" />
</cf:entity>
Here is the set up of my aspect :
<cf:pattern path="SampleAspect.cfp" step="start" name="Sample Aspect" />
Here's a sample model:
The
ClusteredIndexAspect.xml
file (I just add thecf:pattern
tag):The generated tables have clustered index:
EDIT: To add a clustered index to the booking entity, you have to set
cfps:clustered="true"
This will generate the following SQL statement: