c# - "Store update, insert, or delete statement affected an unexpected number of rows (0) -
i'm using ef in order insert simple object db:
public bool addquestion(question question) { try { _ctx.questions.add(question); _ctx.savechanges(); return true; } catch(exception ex) { return false; } }
my dbcontext like:
public class anycontext:dbcontext { public anycontext():base() { configuration.proxycreationenabled = false; configuration.lazyloadingenabled = false; database.setinitializer(new migratedatabasetolatestversion<anycontext, anycontextmigrationconfiguration>()); } public anycontext(string connectionstring) : base(connectionstring) { configuration.proxycreationenabled = false; configuration.lazyloadingenabled = false; database.setinitializer(new migratedatabasetolatestversion<anycontext, anycontextmigrationconfiguration>()); } public dbset<question> questions { get; set; } }
and poco like:
[table("questions")] public class question { public int id { get; set; } public string body { get; set; } public string img_path { get; set; } public int location { get; set; } public int status { get; set; } public datetime ask_date { get; set; } }
and *"store update, insert, or delete statement affected unexpected number of rows (0). * every time
what doing wrong?
Comments
Post a Comment