Reputation: 274
I have a couple of tables I ported over to a new database. Everything is exactly the same from the legacy one to the new one. The back-end code that submits the user generated data to the database is also the same. When I submit changes to the database, all of the submitted information populates the correct columns but the column that stores the GUID populates with all 0's. When I enter in the columns manually using SQL Server Management Studio, the GUID gets populated as it does in the legacy version. Am I missing something?
Upvotes: 1
Views: 280
Reputation: 27431
I've had a similar issue with Entity Framework in the past, even though I have newid()
set as default/initial value on the column. Due to time constraints, I didn't spend much time to resolve it and instead set the Guid property manually/explicitly to Guid.NewGuid()
prior to saving.
Upvotes: 2
Reputation: 5650
When you ported over the tables, you must not have ported over the default value for one of the columns. E.g.
CREATE TABLE blah (
blahID UNIQUEIDENTIFIER PRIMARY KEY DEFAULT NEWID()
)
Upvotes: 0