Identity field going into Insert

0

When I make my insert of the companies table, the CompanyCode field is going on insert , even its property being Identity in my asp.net application. What can I do?

public class EmpresaController : System.Web.UI.Page

{

    Entities context = new Entities();

public void Insert ()

{

        empresa.EmpAtivo = empAtivo;
        empresa.EmpData = empData;
        empresa.EmpMF = empMF;
        empresa.EmpRazao = empRazao;
        empresa.EmpFantasia = fantasia;
        empresa.EmpEndereco = empEndereco;
        empresa.EmpNumero = empNumero;
        empresa.EmpComp = empComp;
        empresa.EmpBairro = empBairro;
        empresa.EmpCidade = empCidade;
        empresa.EmpEstado = empEstado;
        empresa.EmpPais = empPais;
        empresa.EmpCep = empCep;
        empresa.EmpCNPJ = empCNPJ;
        empresa.EmpIE = empIE;
        empresa.EmpMunicipal = empMunicipal;
        empresa.EmpCPF = empCPF;
        empresa.EmpFone = empFone;
        empresa.EmpCel = empCel;
        empresa.EmpEmail = empEmail;
        empresa.EmpMunicipio = empMunicipio;
        empresa.EmpNire = empNire;
        empresa.EmpCnae = empCnae;
        empresa.EmpLogo = null;
        empresa.EmpObs = empObs;            

        context.Empresas.Add(empresa);
        context.SaveChanges();

  }
}
    
asked by anonymous 19.09.2014 / 14:10

1 answer

0

In the database created the field as numeric, so I understood that visual studio was not recognizing that the field was identity. I changed the bank to int and model and it worked normally.

    
19.09.2014 / 15:22