public int CreateDocument(DocumentModel document) { using (geekinsidekmsEntities context = new geekinsidekmsEntities()) { Document dbDocument = new Document { CheckerName = "", Description = document.Description, FileDiskName = document.FileDiskName, FileDisplayName = document.FileDisplayName, Size = document.Size, PubTime = document.PubTime, PublisherName = document.PublisherName, PublisherNumber = document.PublisherNumber, FileTypeId = document.FileTypeId, FolderId = document.FolderId, AuthLevel = document.AuthLevel }; try { context.AddToDocuments(dbDocument); context.SaveChanges(System.Data.Objects.SaveOptions.DetectChangesBeforeSave); } catch(Exception e){ System.Diagnostics.Debug.WriteLine(e.InnerException.Message); } return dbDocument.Id; } }