Hi everyone, I recently have some issues with LINQ2SQL, first of these as that I cant use CRUD methods I dont know whats the matter with LINQ ORM, I cant Update or Delete some entity already mapped in .dbml so I always fix this with drop and renew the .dbml , but now stills not working.
Problem : Entity is not associate already
System.InvalidOperationException was caught Message="No se puede quitar una entidad que no se ha asociado."
Source="System.Data.Linq"
StackTrace: en System.Data.Linq.Table`1.DeleteOnSubmit(TEntity entity) en Resocentro.Informes.PlantillasMedicas.FormPlantilla.elimina(Int32 nro) en D:\cs_PlantillasMedicas\Resocentro.Informes.PlantillasMedicas\ Resocentro.Informes.PlantillasMedicas\FormPlantilla.xaml.cs:línea 54 InnerException:
PD: LINQ XML PrimaryKey Attribute
Snippet for retrieving Entity :
IsPrimaryKey="true"
private PLANTILLA getTemplateEntityFromModel(int codigoPlantilla)
{
using (DB db = new DB())
{
PLANTILLA var = db.PLANTILLAs.FirstOrDefault(x => x.codigoplantilla == codigoPlantilla);
return var;
}
}
Thanks in advance!