0
こんにちは私のデータベースの2つのテーブルを同時に保存しても問題はありませんが、最初のテーブルは問題なく保存されます。 2番目のテーブルは最初のテーブルに関連しており、既にFKを持っています。助けてください。私のコードはありますか?おかげEntity Frameworkを使用してデータベースの2つのテーブルに同時に保存する方法
//Save to Database
//1st Table
casecrawlerdbEntities1 db = new casecrawlerdbEntities1();
document document = new document();
document.DocumentNo = DocumentNo;
document.Description = Description;
document.Author = Author;
document.PublishedDate = DateTime.Parse(PublishedDate); ;
document.Summary = Summary;
document.SearchKeys = richTextBox9.ToString();
document.References = url;
document.IsPublic = false;
document.IsPublished = false;
document.CreatedDate = DateTime.Now;
db.documents.AddObject(document);
db.SaveChanges();
//2nd Table
content content = new content();
content.ContentType = ContentType;
content.Content = Content;
db.contents.AddObject(content);
db.SaveChanges();
MessageBox.Show("Saved to Database");
ありがとうございました。 – guitarPH