Question still remains though, why should I need to set the new GUID anywhere if it is implied that a new id is required when creating a new record in a table who's PK is a GUID?
Here's what I found when looking at the help reference section you pointed me to:
"Validation per entity: implementing IEntityValidator
Validation per entity is not done by default, as an entity has not an implementation of IEntityValidator by default. If you want entity-wide validation functionality, you have to implement IEntityValidator and store an instance of this implementation in the entity object you want entity-wide validation logic being applied to. The generated code performs entity-wide validation, if an IEntityValidator instance is present in the entity, when the entity is saved or when Validate() is called. Validate() is a method of every entity object. It normally returns true, if no IEntityValidator object is present, otherwise it calls the Validate() method of the IEntityValidator instance, passing the complete entity object to it.
A special exception is defined to signal validation failures: ORMEntityValidationException(). It is recommended that a validation failure throws this exception as it will fail (and thus roll back!) transactions started for recursive saves. The exception is also useful to define a special catch clause for this exception to correct validation failures.
Implementing IEntityValidator is very simple. Below is an example of IEntityValidator, which implements simple validation logic for the OrderEntity. The implementation as it is given is usable in SelfServicing and Adapter, however only in source code. You can't share a compiled IEntityValidator class which is compiled against SelfServicing classes with an Adapter assembly. "
' VB.NET
Public Class OrderEntityValidator
Implements IEntityValidator
Public Function Validate(containingEntity As object) As Boolean _
Implements IEntityValidator.Validate
Dim order As OrderEntity = CType(containingEntity, OrderEntity)
If order.OrderDate>order.RequiredDate Then
' error
Throw New ORMEntityValidationException( _
"Order.OrderDate is set to a later date than Order.RequiredDate.", _
containingEntity)
End If
' valid
Return True
End Function
End Class
I figure using the senario above is the closest I'm going to get to what I need however it means that for every entity which uses a GUID as a PK I need to create a custom validator class, check whether the entity being passed in, .IsNew = True and then generate the new GUID? So for each of my entities using a GUID as PK I need this:
' VB.NET
Dim mem As New MembershipUserEntity()
Dim membershipValidator As IEntityValidator = New MembershipUserValidator()
order.EntityValidatorToUse = membershipValidator
As well as implementation of MyEntityValidator?
I didn't realize it was so much work just to get a basic entity to "work".
I'm sorry if I'm not understanding this properly from the documentation any help is much appreciated.