I am encountering a persistent issue with the Breeze.Persistence.EFCore v7.0.1 library while trying to save new entities. The error message I receive is:
Cannot insert the value NULL into column 'id', table 'dbo.Clients'; column does not allow nulls. INSERT fails.
Here's an overview of the situation:
- The issue occurs when saving new entities.
- I'm using a
Guiddata type for theIdproperty/column. - The Id value is automatically generated by
breeze.json the client side. - This
Idvalue is successfully transmitted to the server and is present in the entity. - The
Idproperty is explicitly marked with the[Key]attribute. UPDATEandDELETEare working correctly.
I have verified the entity's state on the server, and it shows the Id with a valid value. This suggests that the issue might not be with the entity's Id assignment or transmission. I suspect there might be a configuration or compatibility issue with Breeze.Persistence.EFCore, especially considering the other operations work fine.
Debugged it till HandleAdded() method where there is a // HACK comment. May it be related somehow? IsTemporary property is set to true there but the RealValue stays null.
Has anyone faced a similar issue or have insights on what could be causing this specific INSERT operation to fail? Any suggestions or guidance would be greatly appreciated.
Thank you in advance for your assistance!
P.S. it's not the first project I develop using Breeze so I believe I made most things right (as usual) so I believe I've set up everything correctly.
UPD
- Updated to
v7.2.1latest stable - didn't help - According to @steve-schmitt advise I tried to set Id manually before save but that didn't help.
BeforeEntitySave()methods fires first and just rewrites the client's value and thenIsTemporaryis set totrueis doesn't care of the value origin and fails the same wasy
UPD2 (workable)
- As @gert-arnold mentioned I forgot to set
AutoGeneratedKeyTypetoNone. Fixed that on client side (breeze.js):
import * as breeze from 'breeze-client';
let manager = new breeze.EntityManager(this.serviceUrl);
manager.fetchMetadata().then(() => {
register(this.manager.metadataStore)
});
function extend(store: breeze.MetadataStore) {
metadataStore.getAsEntityType("Client")
.setProperties({ autoGeneratedKeyType: breeze.AutoGeneratedKeyType.None });
}
After this new entities do not have id at all and set on the server side via BeforeEntitySave(). Despite this is not the way I expected still it works.
Going to open an issue on GitHub and then update the post.

The problem is that
AutoGeneratedKeyTypeisIdentity. You can see that in your QuickWatch screen shot.Identity means that the database will generate the keys, so Breeze should not attempt to insert anything into that column. That's why it makes the RealValue NULL.
I don't think there is a Breeze AutoGeneratedKeyType of "Guid", but that's what would be needed here. Instead, you'll need to use
AutoGeneratedKeyType.Noneand manually generate your Guids on the client.