[英]Insert/Remove not working in Entity Framework 6
我遇到了Entity Framework 6的問題。 Database and . 我有數據庫和 。 當我想插入一條新記錄(或刪除一條記錄)時,該記錄不會在數據庫中添加(或刪除)。
這是我的代碼:
PeopleEntities entities = new PeopleEntities();
Person person = new Person();
person.FirstName = "text here";
person.LastName = "text here";
person.Age = 20;
entities.Person.Add(person);
entities.SaveChanges();
請注意,獲取這樣的記錄:Entitys.Person.ToList(); 正在工作。
嘗試將mdf
文件的“ Copy to output
屬性更改為Do not copy
在解決方案資源管理器中Do not copy
。 我的猜測是,每次您運行該應用程序時,它都會被擦除。
聲明:本站的技術帖子網頁,遵循CC BY-SA 4.0協議,如果您需要轉載,請注明本站網址或者原文地址。任何問題請咨詢:yoyou2525@163.com.