Closed denovellis closed 1 month ago
I would like to provide some additional information regarding the issue I reported earlier with DatabaseGeneratedOption.None. I've noticed an interesting behavior that might help in diagnosing the problem:
When I use the source code directly from the repositories of Dommel and FluentMap.Dommel, everything works as expected, and the system correctly uses the provided value for insertion without attempting to auto-increment.
However, when I switch to using the NuGet packages of these libraries, even though the versions are identical to those in the source code I initially tested with, the problem occurs where it tries to insert an auto-increment value instead.
This behavior suggests that there might be a discrepancy between the packaged versions on NuGet and the latest source code in the repositories, despite them having identical version numbers.
Dapper.FluentMap is archived and might not be compatible with the latest version of Dommel. Can you try using attribute mapping instead? E.g. [DatabaseGenerated(DatabaseGeneratedOption.None)]
.
Hi,
I've encountered a problem where, even though DatabaseGeneratedOption is set to None, the system is still attempting to perform an insertion with an auto-increment value instead of using the provided value for the insert.
Steps to Reproduce: Configure a model with DatabaseGeneratedOption set to None. Attempt to insert a record into the database by explicitly providing a value for the primary key. Observe that an auto-increment value is being used instead.
Expected Behavior: The system should use the value provided for the insertion, as DatabaseGeneratedOption.None suggests that the value will not be automatically generated by the database.
Generated sql (found via profiler):
exec sp_executesql N'set nocount on insert into [Business] ([Name], [Count]) values (@test_name, @test_count); select scope_identity()',N'@test_count int,@test_name nvarchar(4000)',@test_count=0,@test_name=N'test'
` class Program { static void Main(string[] args) { Dapper.FluentMap.FluentMapper.Initialize(config => { config.AddMap(new TestMap()); config.ForDommel(); });
}
public class Test { public string test_id { get; set; } public string test_name { get; set; } public int test_count { get; set; }
}
public class TestMap : DommelEntityMap
{
public TestMap()
{
ToTable("Business");
}`