I'm developing an app where I need to insert names using special characters like áéíóúñ and I'm using linq to entities with Visual C#.
My database server is SQL 2008 express and the default collation of my database is SQL_Latin1_General_CP1251_CI_AS, however I changed the collation of the fields to SQL_Latin1_General_CP1_CI_AI where I need to insert the special characters mentioned above.
If I insert names with special characters using code similar to this:
Cliente cli = new Cliente()
{
Nombres = cliente.nombres,
ApellidoP = cliente.apellidoP,
ApellidoM = cliente.apellidoM,
FechaNac = cliente.fechaNacimiento
};
context.clientes.AddObject(cli);
context.SaveChanges();
The special characters are translated to their equivalent, but if I insert names with special characters directly in the database (management studio) I have no problems inserting those characters.
I changed fields collation to SQL_Latin1_General_CP1_CI_AI after creating my project in visual studio, so I thought updating model from database would solve the problem but I was wrong. I also used the debugger to check if special characters were present when I create a new instance of Cliente object, and yes, they're there.
What could be the problem?