0
我目前工作的一個ASP.NET MVC項目,允許用戶將文件上傳到服務器上刪除之後調用的函數,並把它們與其他對象實體框架:一個對象被從數據庫
public class FileAttachment
{
[Key]
public int Id { get; set; }
public string Title { get; set; }
public string ContentType { get; set; }
public string Extension { get; set; }
[ForeignKey("Donor")]
public int DonorId { get; set; }
public virtual Donor Donor { get; set; }
}
public class Donor
{
[Key]
public int Id { get; set; }
// .....
public virtual List<FileAttachment> Attachments { get; set; }
}
關聯
我想知道的是,如果有一種方法可以指定實體框架在從DbSet中移除Donor或FileAttachment對象時執行的函數,因爲附件存儲在文件系統中,所以我需要確保文件被刪除。
那麼它是你想要刪除的磁盤上的物理文件? –
這是9小時前問的。 http://stackoverflow.com/questions/17214008/delete-a-file-from-database-and-file-system – qujck