Skip to content

Insert when primary key is VARBINARY(16) Guid #315

@jkuek

Description

@jkuek

[Edited with new information]

My app is using MySqlConnector with an AWS Aurora server and I have a table with an Id field of type VARBINARY(16).

I've been trying to migrate from Dapper.SimpleCrud but can't seem to get it to set my Id field correctly on InsertAsync().

Dommel seems to support the following scenario (according to the integration test): insert to MS SQL server, database server generates the GUID, and Dommel reads it back. This doesn't transfer to MySQL as there's no way to read back the generated GUID of an inserted row.

I added [DatabaseGenerated(DatabaseGeneratedOption.None)] attribute to the Id property and generated the Guid in my app. Dommel then explicitly sets the Guid, but sends the value as a string rather than VARBINARY(16).

Is the correct approach to create a new class inheriting from MySqlSqlBuilder, override BuildInsert and then do the conversion manually?

Is automatic conversion from Guid/VARBINARY(16) a feature that could be added?

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions