c# - Entity Framework Save not working -
i using entity framework save info in sqlite database file.
this table in db file
id name username pwd
id
autoincrement, , rest of columns of text
type
this how saving info database:
userinfo userinfo=new userinfo(); userinfo.name="abc"; userinfo.username="xyz"; userinfo.pwd="123456"; using (var context = new applicationcontext()) { context.userinfo.add(userinfo); context.savechanges(); }
the problem is, code not inserting new row table. tried before saving, no luck
context.entry<userinfo>(userinfo).state = entitystate.added; context.changetracker.detectchanges();
i tried debugging , no exception occurring.
how can insert new row table using entity framework?
possibilities may cause issue.
right click on entity info model , update model database. create sure have updated till lastly change. make sure looking @ right database , table. every 1 makes error 1 time in while. make sure using valid connection string. pointing proper databases. create sure not old db / other backup db. make sure using proper entity date.the above code have, working fine me. did workout sort out issue.
the above points guesses.
refer link entity info model example & one more illustration code available here
c# entity-framework
No comments:
Post a Comment