The article here : http://msdn.microsoft.com/en-us/library/ee536168.aspx describes how to set the unique field using code, I guess you could put this code in the feature receiver activated event.
Is there an easy way to define field uniqueness in the XML field definition.
My first guess would be :
<Field
Type="Number"
ID="{01FC2C92-07A1-4AE3-9D28-C13B22A49804}"
Name="ID"
DisplayName="ID"
StaticName="ID"
Indexed="TRUE"
EnforceUniqueValues="True"
Group="OrgStructure"
>
</Field>
But I'm getting this error:
Error occurred in deployment step 'Activate Features': This field must be indexed to enforce unique values
Update:
I realized I was setting this in the raw field definition, not in the list instance where I think it would be more suitable, so I added All fields of the content type to the fields collection for the list instance, and set the property there, no error during deployment, but it ignores the unique binding.