-
Notifications
You must be signed in to change notification settings - Fork 303
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Insert() returns null on Simple.Data.SqlServer when PK isn't an autoincrementing int #370
Comments
Hi. Yes, at present Simple.Data.SqlServer only returns inserted records when there is an IDENTITY column. v2 should address this. As a technical note, using |
If I could click "like" on what markrendle said "As a technical note", I would. If you really want to use GUID, you could disabale identity and work like this var id = System.Guid.NewGuid() |
I agree with the "technical note", however there are cases when uniqueidentifier's are invaluable. For example I have built a number of databases that participate in a custom built replication system. Trying to merge records (with child records and relations) without guid primary keys is a nightmare. The other place that they really helped is that these databases partition data by Customer. So each Customer gets their own copy of data but it is all stored within the same tables. Trying to build composite keys and links to other tables separated by Customer in a setup like this would be horrible. Mark, how are you doing on Simple.Data 2.0? I know your busy as hell building your cloud services etc. I hope you still find some time to play on that xbox :-) |
I completely agree that uniqueidentifiers are invaluable for a range of use cases. Many of the databases I design use GUIDs as secondary ID columns, but I always use a BIGINT IDENTITY as the PK. Simple.Data 2.0-beta1 is on course for a release next month, and I feel a blog post is in order... |
Point taken about GUIDs as PKs. Where we do use them, we do either |
Mark, so then you would use that Secondary key for foreign keys? Interesting, I never thought about it that way. jrnail23, yes I use newsequentialid() as well. What do you mean by CombGuid? |
@WayneHiller, a CombGuid is an algorithm that creates a sequential GUID in application code. Also, more info here: GUIDs as fast primary keys under multiple databases |
Thanks @jrnail23, I have cases where I do indeed assign the GUID's from code, especially when doing large data imports, Using CombGuid's in that case would make a lot of sense. Thank you very much for the info :-) |
Here's the reproduction (w/ SQL Server 2012 Express, using Simple.Data.SqlServer):
In this case,
example
always ends up null, unless I change theID
column (the primary key)to
[ID] [int] IDENTITY(1,1)
The text was updated successfully, but these errors were encountered: