0

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.

Community
  • 1
  • 1
amiry jd
  • 27,021
  • 30
  • 116
  • 215
  • 2
    I think there is just one up vote because not too many people are implementing custom id generation. Not sure what your requirements are, but it rarely passes the smell test in my opinion. – Maess Sep 28 '12 at 13:21
  • @jrummell If you see question clearly, you'll see I point your link myself. But thanks to pay attention – amiry jd Sep 28 '12 at 13:27
  • @Maess Thanks. If you post your test as an answer, I'll accept it – amiry jd Sep 28 '12 at 13:28
  • 1
    That's how I found it :) Your question should really be a comment on that linked question. – jrummell Sep 28 '12 at 13:30
  • Why do you think that votes show which solution is correct for you? Did the answer helped you? If yes, use it. Btw. if it has one vote and it helped you, you should also add your own vote. The answer is correct. I didn't know about that option when writing my own answer. – Ladislav Mrnka Sep 28 '12 at 17:14

1 Answers1

1

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.

Maess
  • 4,118
  • 20
  • 29