c# - Debug blackbox DbContext.SaveChanges() when it doesn't -


i have simple sample program begin grips reality of entity framework 5. have read fair amount of theory , seems run problem saving database.

the problem have dbcontext.savechanges() neither throwing exception (which expected) nor saving data.

heres code:

     public class physicaladdresstype         {             [key]             public long addresstypeindexcode { get; set; }              public string tname { get; set; }              public long clientid { get; set; }              public guid userid { get; set; }              public datetime lastmodified { get; set; }           }          public class testcontext : dbcontext         {             public testcontext() : base("name=basd.contactmanagement") { }              public dbset<physicaladdresstype> addresses { get; set; }         }       static void main(string[] args)             {                 try                 {                      using (var ctx = new testcontext())                     {                         var ph = new physicaladdresstype();                         ph.clientid = 500;                         ph.userid = guid.newguid();                         ph.tname = "test1";                         ph.lastmodified = datetime.now;                         ctx.addresses.add(ph);                         ctx.savechanges();                      }                 }                 catch (exception ex)                 {                     system.diagnostics.debug.writeline(ex.message); }         } 

i expect code throw exception because have not provided mapping table in database. here schema of table:

create table [erp_crm].[physicaladdresstype](     [addresstypeindexcode] [bigint] identity(1000,1) not null,     [tname] [nvarchar](50) not null,     [clientid] [bigint] null,     [userid] [uniqueidentifier] null,     [lastmodified] [smalldatetime] not null,  constraint [pk_physicaladdresstype] primary key clustered  (     [addresstypeindexcode] asc )with (pad_index  = off, statistics_norecompute  = off, ignore_dup_key = off, allow_row_locks  = on, allow_page_locks  = on) on [primary] ) on [primary]  go 

but doesn't , nor store record in database.

so question how debug @ point? first question whether it's hitting db, not because connection string wrong (in app.config) other reason. "silent failure" real part of ef experience?

my first question whether it's hitting db,

you can use sql server profiler (or other custom profiler independant vendors) purpose. displays ative connections , queries, being executed. suggest try reading context check if hit db.

so question how debug @ point?

have tried use step-into framework source debuging feature?

you have source code last resort (you can build , debug app against produced binaries).


Comments

Popular posts from this blog

SVG stroke-linecap doesn't work for circles in Firefox? -

routes - Laravel 4 Wildcard Routing to Different Controllers -

cross browser - XSLT namespace-alias Not Working in Firefox or Chrome -