asp.net mvc - EntityFramework concurrecy error at first record -


this object image

[key] public int id { get; set; }           //primary key public string path { get; set; } //not null public string name { get; set; } //not null public string url { get; set; }  //allows null public string secureurl { get; set; } //allows null 

efdbimagerepository

public void uploadtocloud(image image) {     system.diagnostics.debug.writeline(image.id);     if(image.id == 0)     {         context.images.add(image);     }     context.savechanges(); } 

in controller in uploadimage action

 ...     image image = new image();  image.init(path, "defaultname1", "type");  imagerepository.uploadtocloud(image);  ... 

at moment savechanges have en exception: system.data.entity.infrastructure.dbupdateconcurrencyexception in entityframework.dll

also find message: entity of type image in state added not updated

as know concurrecy error occures when 2 users try modify 1 data @ same time. in mvc project user load file @ form. form sends post request controller, saves image server , database. run app @ localhost , can load images. still haven't add records.

how add record database entity framework?


Comments

Popular posts from this blog

java - Suppress Jboss version details from HTTP error response -

gridview - Yii2 DataPorivider $totalSum for a column -

Sass watch command compiles .scss files before full sftp upload -