-
[EFCore] Key 값 넣을 때C#/EFCore 2023. 10. 6. 11:32
[DatabaseGenerated(DatabaseGeneratedOption.Identity)]
자동으로 Key값 증가
Id 에 null 값(값을 안 넣어도) 자동으로 1부터 넣어줌.
Id = 1, Id=2 넣어도 되는데
Id = 0 은 에러.
Id = 0 이 가능하게 하려면
[DatabaseGenerated(DatabaseGeneratedOption.None)]
자동증가 못하게 하고 넣으면 가능.
728x90'C# > EFCore' 카테고리의 다른 글
[EFCore] reset sqlite_sequence (0) 2023.10.12 [EFCore] Grpc Data Parsing (0) 2023.09.21 [EFCore] SQLite .db 사용시 Close (0) 2023.08.29 [EFCore] 시작하기 (0) 2022.11.09 댓글