I have this model generated by EF
public partial class Ventas
{
public Ventas()
{
this.Caja = new HashSet<Caja>();
this.VentasLinias = new HashSet<VentasLinias>();
}
public string weblogin { get; set; }
...
...
}
But I use this other one by means of automapper to do the operations of insertion in the BD.
public class VentasModel
{
public string weblogin { get; set; }
...
public List<Caja> caja { get; set; }
public List<VentasLinias> linias { get; set; }
}
When trying to save in the BD, this error gives me the code I use is this
try
{
var destino = mapper.Map<VentasModel, Ventas>(venta);
db.Ventas.Add(destino);
db.SaveChanges();
}
catch (Exception ex)
{
string error = ex.Message;
}
The error I receive is this
Only keys generated by storage for identity columns are supported. The key column 'weblogin' has the type 'SqlServer.varchar', which is not a valid type for an identity column.
In the database I have this table where I consider a key composed of these three fields.
Thank you,