Question

Possible Duplicate:
DBContext Added/Attached Event?

I'm using a custom ID-Generating strategy in EF 5. I override the SaveChanges method to detect added entities and set them IDs. But the new entities's ID is not accessible until calling SaveChanges. I search SO and find some answers. Here and here. In the second link, @KVerwold's answer shows a way to detect changes that seems works. But it has just one up-vote and not accepted. Can I use @KVerwold's suggested way? Do you think it may couse any error -logical or any? OR do you have any other suggestions please? Thanks in advance.

Was it helpful?

Solution

I suggest that unless there is a strong business requirement for custom Ids, you not implement them. I think there is just one up vote for the post you mention because not too many people are implementing custom id generation as it doesn't pass the smell test, in my opinion.

Licensed under: CC-BY-SA with attribution
Not affiliated with StackOverflow
scroll top