ID column Auto Generated

I found a thing in the actual version of Aurelius that I think is not fully correct:

Declaring a column ID with a generator like TIdGenerator.Guid does not allow the code to assign an ID manually.
Usually DB does not work in this manner because sometimes you need to import records with an ID that you have to preserve.

Thinking to use the TIdGenerator.None clause I need that TMS Data Modeler do not force the automatic generation clause.
Any suggestion? 

This is by design, if you want to assign the id manually, then the generator is "none" (meaning you don't want Aurelius to generate it for you). The only downside is that Aurelius won't know if the object is must be inserted (a new one) or updated (an existing one) but you would have the same problem anyway if you were able to manually assign a value to a GUID generator.

A little modify to your source could allow more flexibility:


procedure TObjectManager.Save(Entity: TObject; bAcceptManualID: boolean =
false);
var
  ProcessedObjs: TList<TObject>;
  DeletedObjs: TList<TObject>;
begin
  // TODO: Change this for a transactional context
  ProcessedObjs := TList<TObject>.Create;
  DeletedObjs := TList<TObject>.Create;
  try
    InternalSave(Entity, DummyMasterObject, ProcessedObjs, DeletedObjs, bAcceptManualID);
  finally
    DeletedObjs.Free;
    ProcessedObjs.Free;
  end;
end;

procedure TObjectManager.InternalSave(Entity: TObject; MasterObj:
TMasterObjectValue; ProcessedObjs, DeletedObjs: TList<TObject>;
bAcceptManualID: boolean = false);
var
  Inserter: TInserter;
begin
  // Avoid recursion
  if ProcessedObjs.IndexOf(Entity) >= 0 then Exit;
  ProcessedObjs.Add(Entity);

  // if there is a persistent object with same id (either same object or another one), raise an error
  if FObjects.IsIdMapped(Entity) then
    raise EObjectAlreadyPersistent.Create(Entity);

  // If the object already has an id value but the generator doesn't require a value, then raise an error
  if FObjects.HasIdValue(Entity) and not Explorer.GetId(Entity.ClassType).IsUserAssignedId then
  if bAcceptManualID = false then
    raise ECannotSaveWithId.Create(Entity);
...

It works but of course at the next release of Aurelius I'll have to modify it again.
Do you think it could be something you can consider to add?

We will have to review it better and think what is the best way to do it (according to our guidelines). Personally, I don't like default parameters in such high level, high used methods. We might probably end up with a different method name.

Many thanks for your answer.

I agree with you regarding default parameters and I'm sure you'll find the best way for that.

As we do data migration between database as well, we would require this functionality too. Any progress on this? Maybe an extra attribute for allowing identity-inserts?

For data migration users usually build a different mapping setup where they manually change the generator for the column at runtime. But yes, we should consider something like that. May I suggest that you add a feature request so it can be voted?