You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
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();
});
var conn = new SqlConnection("XXXXXX");
var a1 = conn.SelectAsync<Test>(test => test.test_name.Contains("*test*")).Result;
Console.WriteLine(a1.Dump());
var a2 = conn.InsertAsync<Test>(new Test { test_id = "X", test_name = "test", test_count = 0 }).Result;
Console.WriteLine(a2);
}
}
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");
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.
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");
}`
The text was updated successfully, but these errors were encountered: