How to auto-generate _id?
See original GitHub issueI wanted to use example from this answer, but it throws:
LiteDB.LiteException
HResult=0x80131500
Message=Invalid BSON data type 'Null' on field '_id'.
Source=LiteDB
I thought that LiteDB will auto-generate ‘_id’. I don’t mind it. In this example there is no ‘_id’ in BsonDocument, so I assume it is somehow auto-generated.
Any clues?
Edit:
I now see that this feature is removed from LiteDB 4.0. So how could I substitute it?
Issue Analytics
- State:
- Created 6 years ago
- Comments:10 (4 by maintainers)
Top Results From Across the Web
How to auto generate id [duplicate]
Create an ID column in your database (I am guessing you are using MS SQL because you stated only C#). · Set Identity...
Read more >Returning an Auto-Generated Id with JPA
In this tutorial, we'll discuss how we can handle auto-generated ids with JPA.
Read more >AUTO GENERATING AN ID IN ASP.NET - YouTube
In this video, we'll be demonstrating how to generate a unique auto generated id using SQL Server. This id can be used to...
Read more >i want to auto generate id in the format IDA201912000001
In other way, and probably the best, is to store this number in a table of "counters" and increment that number.
Read more >Solved: Auto generate ID Number - Power Platform Community
Solved: Hi I am new to Power Apps How to autogenerate ID number in power apps form and save that in SharePoint list....
Read more >Top Related Medium Post
No results found
Top Related StackOverflow Question
No results found
Troubleshoot Live Code
Lightrun enables developers to add logs, metrics and snapshots to live code - no restarts or redeploys required.
Start FreeTop Related Reddit Thread
No results found
Top Related Hackernoon Post
No results found
Top Related Tweet
No results found
Top Related Dev.to Post
No results found
Top Related Hashnode Post
No results found
Top GitHub Comments
Hi @qqgg231, “auto index” is not the same “auto id”.
Auto index is create an index based on query execution (when you just run a query and database create an index if need). This feature was removed because now LiteDB supports full scan search too (search with no index).
Auto Id is like “Auto Increment” in sql server. This was removed in
LiteDatabase
level (any POCO class) and was implemented inLiteEngine
level (BsonDocument only).(sometimes is not too clear for anyone but me 😄)
Oh, I found the reason: https://github.com/mbdavid/LiteDB/blob/0bf2c327e2ebb91c5b8448c77df1652b921c81d2/LiteDB.Tests/Database/AutoId_Tests.cs#L82
I changed my Id property from
string
toGuid
now and it’s working 😄