DataValidationRuntimeException when setting value to a property

When I try to set value to a property on my entities it throws DataValidationRuntimeException. This happens only when I try to set a value for a unique property, and if that value already exists in the database. How can I avoid this, why is this happening.
1 answers

If you have a property that is set to unique (customernumber etc). It should be unique. So either remove the unique validation rule or assign a unique number.