Vote count:
0
I was using .EDMX file version 2, using legacy ObjectContext.
I updated to codestrategy T4, and updated references and config files for Entity Framework 6.2
I'm using LazyLoadingEnabled = true (before and after the upgrade);
Old objectcontext :
ret = new PropertySet {
display_name = DisplayName,
id_product = IdProduct // this is a foreign key to the entity Product
};
context.PropertySets.Add(ret);
context.SaveChanges();
// calling ret.Product returns the product object with all properties filled.
New DbContext :
ret = new PropertySet {
display_name = DisplayName,
id_product = IdProduct // this is a foreign key to the entity Product
};
context.PropertySets.Add(ret);
context.SaveChanges();
// calling ret.Product returns null. (HERE IS THE PROBLEM)
// calling context.Entry(ret).Product.Load() loads the correct Product.
I'm worried about this 'new' behavior because it breaks existing code, with runtime error. This is a big app and we don't have tests against EF.
I'm wondering if there's is some option or something that's wrong or it is just a new way of doing things? Am I missing something ?
Thanks, I really appreciate any clue, I was looking around all day, since lots of bugs has been introduced to the app because of this different behavior.
asked 42 secs ago
Aucun commentaire:
Enregistrer un commentaire