Closed displaced closed 8 years ago
can you post the SQL for your table?
sqlite or sql server?
Not all tables use auto incremented primary keys and therefore it's not turned on per default.
To allow Griffin.Framework to pick up the generated value you need to configure it:
public class ClientMapper : CrudEntityMapper<Model.Client>
{
public ClientMapper() : base("Clients")
{
Property(x => x.Id)
.PrimaryKey(true); //true = autoinremented
}
}
reopen if that's not your issue.
Hi,
I've got a simple POCO ('Model.Client') which matches exactly my database fields. The mapper for that is defined as:
...which I believe is the correct way to define a mapper if the model properties match the database fields.
Now, if I insert an instance of this model as so:
...the row is added to the database table correctly, but
ret
is null. I believe this should either be the identity of the newly-inserted row, or an instance of the model that was inserted with the .Id property set appropriately.My database correctly has an auto-incrementing primary key column named
Id
, and my entity object has a matchingint Id { get; set; }
property defined.No exceptions appear to be thrown. I'm using the latest version of Griffin.Framework as available on NuGet.
It's almost as if the mapper hasn't picked up the presence of the Id field. Is there any way to see what's going on inside the mapper during use?
Any advice greatly appreciated!