Insert data with Entity and no field identity

0

I have this method to insert into the database:

public virtual void Inserir(T item) 
        {
            contexto.Set<T>().Add(item);
            contexto.SaveChanges();
        }

And I have this in my Product entity, for example:

.......
[Key]
[DatabaseGenerated(DatabaseGeneratedOption.None)]
public int IdProduto { get; set; }
.......

See that DatabaseGeneratedOption is None and not Identity , this I did, because the field is not Identity , I thought I could not put it for that reason and I do not know if it would increase, to accompany the bank on the client, which has no Identity at all. How would I make the ID field incremental as I insert it. I do not want to play tricks, to get atual + 1 , I do not want to do it. T is of type class

    
asked by anonymous 17.08.2017 / 00:07

0 answers