I've been playing with this some more and reading the documentation again and I'm more confused than I was before. The developer's guide states on page 203 that "Unless the primary key is an identity column, DevForce doesn't know how to generate an object's primary key identifier(s)".
Also the API documentation for the method GenerateId states "If you are using a SQL Server Identity property you do not need to call GenerateId for the property".
In my case our "BatchStatus" database table has a PK column named "ID" that is defined as an identity key and the datatype is "tinyint".
Since the ID column is an identity column I'm confused why I need to call GenerateId at all?
When I run my code the GenerateId call fails with the error mentioned above (Value was either too large...).
The stacktrace is as follows:
at System.Convert.ToByte(Int64 value)
at System.Int64.System.IConvertible.ToByte(IFormatProvider provider)
at System.Convert.ChangeType(Object value, Type conversionType, IFormatProvider provider)
at IdeaBlade.EntityModel.StoreGeneratedIdGenerator.GetNextTempId(DataEntityProperty property)
at IdeaBlade.EntityModel.EntityManager.GenerateId(Object entity, DataEntityProperty entityProperty)
at IdeaBlade.EntityModel.EntityManager.UpdatePkIfNeeded(EntityWrapper wrapper)
at IdeaBlade.EntityModel.EntityManager.AddEntityWrapper(EntityWrapper wrapper)
at IdeaBlade.EntityModel.EntityAspect.AddToManager()
at OrianaHouse.CMIS.UI.UIFactory.C1DataGrid_BeginningNewRow(Object sender, DataGridBeginningNewRowEventArgs e)
In the stacktrace it looks like the "GetNextTempId" method was called on the "StoreGeneratedIdGenerator" object instead of my custom IdGenerator. The error is clearly occurring when the code tries to convert an Int64 value to a Byte value. Why was an Int64 value passed in in the first place if the column is defined as a tinyint?
Does DevForce assume all identity columns are Int64?
So in summing up I am now confused as to whether or not I even need a custom IdGenerator. If I do need a custom IdGenerator I'm not sure where to put it in my project. As of now I've placed it everywhere except for the DataModel itself on the server side and everytime I run my code the built-in IdGenerator seems to be called instead of my own.
Could someone shed some light on where I'm going wrong here. I think I'm missing something very basic here. Thanks in advance!