c# - Entity Framework Doesn't Return Primary Key -


I'm killing my head against the wall. I have reviewed and tried every solution given here, But nothing is working.

It sounds simple, yet here I am.

I have a database-before, unit structure model that uses stored procedures, stored procedures are assigned through ADMX Designer. I'm called attraction, which is a related table called a configuration, ideally, what I want to do is save the attraction object, the configuration object, and save them with a call.

Attraction Attractions = New Attractions (); Configuration config = new configuration (); & Lt; ... Assign properties for attraction ... & gt; & Lt; ... Assign properties to configure ... & gt; Attraction.Configurations.Add (config); // now we save (! Antireir.adv.te. (wrong, attraction)) {DisplayNotification (string format ("Error saving an error, {0}", a.AttractionCode) is true); return false; } & Lt; ------- My Service Layer ------- & gt; Public Virtual Bull AddUpdate (bool isUpdate, T unit) {try {if updated}} {Return (repository update T & gt; (entity)); } Other {Returns (repositories. Creating & lt; T & gt; (Organization)! = Null); }} Hold (EntityCommandExecutionException pre) {Logger.Error (ex.Message); return false; } Hold (ArgumentException aex) {logger Error (aex.Message); return false; } Hold (exception before) {Logger.Error (ex.Message); return false; }} & Lt; ------- Methods of Making Me ------- & gt; Create public virtual te & lt; T & gt; (T object) where T: class {try {var newItem = dbContext.Set < T & gt; (). Add (TOBJ); DbContext.SaveChanges (); DbContext.Entry & LT; T & gt; (NewItem) .Reload (); Return new item; } Hold (DbEntityValidationException ex) {var errors = ex.EntityValidationErrors; String msg = string Empty; Foreach (DbEntityValidationResult error in errors) {var errs = error.ValidationErrors; Foreign Currency (DbValidationError er errs) {msg+ = er.ErrorMessage + "\ n"; }} wood cutter. Error ("DbEntityValidationException error in creating record:" + msg, ex); Return tap; } Hold (argument expression pre) {Logger.Error ("Logic Expression Error in creating record.", Prior); Return tap; } Hold (prior to dbepadate exception) {logger Error ("DbUpdateException error in creating record.", Prior); Return tap; } Hold (exception preceding) {Logger.Error ("Error creating record.", Formerly); Return tap; }}

Nothing works for I tried to save the attraction before, but the primary key never returns. It holds the value of 0, even when I reload the object. In the Edmx Designer, I tried to 'Result Column Binding' property to 'Attraction' (my primary key field), but nothing. I have returned Scope_Identity () in the included stored procedure.

Like I said, I am at the end of my mind. I have no clue what I am missing.


Comments

Popular posts from this blog

sqlite3 - UPDATE a table from the SELECT of another one -

c# - Showing a SelectedItem's Property -

javascript - Render HTML after each iteration in loop -