-
Notifications
You must be signed in to change notification settings - Fork 53
Open
Description
Hi, I'm having an issue where EF6 context.Entity.Add(entity) not auto-incrementing its Primary Key after inserting the data.
I'm currently using the following nuget packages in a .NET Framework 4.8 project:
- EntityFramework6.Npgsql v6.4.3
- Npgsql v4.1.3
\d "ErrorLog":
Minimum reproduceable repo can refer to: https://github.com/chinyik94/NpgsqlSample
Entity model file:
'------------------------------------------------------------------------------
' <auto-generated>
' This code was generated from a template.
'
' Manual changes to this file may cause unexpected behavior in your application.
' Manual changes to this file will be overwritten if the code is regenerated.
' </auto-generated>
'------------------------------------------------------------------------------
Imports System
Imports System.Collections.Generic
Partial Public Class ErrorLog
Public Property ErrorLogId As Integer
Public Property ErrorDetails As String
Public Property DateCreated As Date
End ClassAdding new data to entity:
Using context As New C4WX1Entities
Dim errorLog As New ErrorLog
errorLog.ErrorDetails = "Test Error"
errorLog.DateCreated = Now()
context.ErrorLog.Add(errorLog)
context.SaveChanges()
End UsingExpected:
ErrorLogId = 1, ErrorDetails = "Test Error", DateCreated = Now
Actual:
ErrorLogId = 0, ErrorDetails = "Test Error", DateCreated = Now
I also tried using negative ID as recommended in npgsql/efcore.pg#1391, but the Primary Key inserted is -1 instead if I provide the value.
Metadata
Metadata
Assignees
Labels
No labels
