aspnetboilerplate - Cannot delete record from table which has Identity column -


i have table has code primary key instead of id, when call deleteasync method exception message = "cannot update identity column 'id'.".

[table("test")]  public class test: fullauditedentity<int>  {  [databasegenerated(databasegeneratedoption.identity)] new public int id { get; set; } [key] [databasegenerated(databasegeneratedoption.none)] public virtual int code { get; set; }  public async task deletetest(int code)     {           try         {             await _supplierrepository.deleteasync(p => p.code== code);         }         catch (exception ex)         {          }     } 

but if remove id column table, works fine. want both id column , code column pk.

what happening is, fullauditedentity<int> automatically creates id field of integer. don't need this:

[databasegenerated(databasegeneratedoption.identity)] new public int id { get; set; } 

if want create table composite key, go ahead , add code field without replicating id field. have no problems.


Comments

Popular posts from this blog

angular - Ionic slides - dynamically add slides before and after -

minify - Minimizing css files -

Add a dynamic header in angular 2 http provider -