code as below:
Mailinglists_Details _addMail_Details = new Mailinglists_Details();
_addMail_Details.listname = mailingData[counter].listname;
_addMail_Details.usage = mailingData[counter].usage;
_addMail_Details.responsible = mailingData[counter].responsible;
db.AddToMailinglists_Details(_addMail_Details);
db.SaveChanges();
as you might see from the code yourself: Entities db = new Entities()
AddToMailinglists_Details(obj) is a shortcut for AddObject("Mailinglists_Details", obj)
for clarification:
[global::System.CodeDom.Compiler.GeneratedCode("System.Data.Entity.Design.EntityClassGenerator", "4.0.0.0")]
public void AddToMailinglists_Details(Mailinglists_Details mailinglists_Details)
{
this.AddObject("Mailinglists_Details", mailinglists_Details);
}
the strange thing now is, when creating some dummy records using the exactly same syntax works. The only difference to the dummy records is, that the entity is declared explicitly and not in a using statement, could that cause the problem? (mind that the comparison inside the same using assembly worked!!)
EDIT: For further clarification, the Table i am accessing is fully independent, here you got some code on how the dummy data are generated:
Mailinglists_Details _addDetails_Mail = new Mailinglists_Details();
_addDetails_Mail.listname = "apprentices@domain.com";
_addDetails_Mail.usage = "Contact all apprentices @enterprise";
_addDetails_Mail.responsible = "default responsible: some ppl";
ent_mail.AddToMailinglists_Details(_addDetails_Mail);
ent_mail.SaveChanges();
i have also tried mailingData[counter].listname.ToString();
EDIT2: mailingData is List<customClass>, Custom Class extends 4 properties: listname(string), usage(string), responsible(string), recipients(string[])
Try
db.MalingLists.Add(_addMail_Details);instead of the call todb.AddToMailinglists_Details– it’s possible there’s a problem in the method you’ve created.