c# - Having trouble getting Entity Framework to savechanges -
first post here bare me.
i have entity framework set create entity object. no exception thrown. when put in break point entity object seems catch data nothing gets committed db.
take look:
var dbctx = new firsthanddm();//datacontext var newcontact = new contact();//entity object newcontact.first_name = firstname.text; newcontact.last_name = lastname.text; newcontact.company = companyname.text; newcontact.phone = phone.text; newcontact.email = emailaddress.text; dbctx.contacts.add(newcontact); dbctx.savechanges();
i running entity framework 6.0.
here app.config
<?xml version="1.0" encoding="utf-8"?> <configuration> <configsections> <!-- more information on entity framework configuration, visit http://go.microsoft.com/fwlink/?linkid=237468 --> <section name="entityframework" type="system.data.entity.internal.configfile.entityframeworksection, entityframework, version=6.0.0.0, culture=neutral, publickeytoken=b77a5c561934e089" requirepermission="false" /> </configsections> <startup> <supportedruntime version="v4.0" sku=".netframework,version=v4.5.2" /> </startup> <entityframework> <defaultconnectionfactory type="system.data.entity.infrastructure.localdbconnectionfactory, entityframework"> <parameters> <parameter value="mssqllocaldb" /> </parameters> </defaultconnectionfactory> <providers> <provider invariantname="system.data.sqlclient" type="system.data.entity.sqlserver.sqlproviderservices, entityframework.sqlserver" /> </providers> </entityframework> <connectionstrings> <add name="firsthanddm" connectionstring="data source=(localdb)\mssqllocaldb;attachdbfilename=|datadirectory|\firsthanddb.mdf;integrated security=true;multipleactiveresultsets=true;app=entityframework" providername="system.data.sqlclient" /></connectionstrings> </configuration>
Comments
Post a Comment