Puede hacerlo sin embargo, requiere un trabajo manual. Requiere FILESTREAM
para ser habilitado.
https://docs.microsoft.com/en-us/sql/relational-databases/blob/enable-and-configure-filestream
tabla, observe la columna de la unique rowguidcol not null
IdFile que se requiere.
CREATE TABLE [dbo].[Files](
[id] [int] IDENTITY(1,1) NOT NULL,
[IdFile] [uniqueidentifier] unique ROWGUIDCOL NOT NULL,
[Title] [nvarchar](max) NULL,
[File] [varbinary](max) FILESTREAM NULL,
CONSTRAINT [PK_Table_1] PRIMARY KEY CLUSTERED
(
[id] ASC
))
GO
ALTER TABLE [dbo].[Files] ADD CONSTRAINT [DF_Files_IdFile] DEFAULT (newid()) FOR [IdFile]
GO
modelo de EF, la columna IdFile no está presente, sólo contiene los valores por defecto y es de ninguna utilidad para nosotros. Sólo se utiliza por SQL Server:
[Table("Files")]
public class FileModel
{
public int Id { get; set; }
public string Title { get; set; }
public byte[] File { get; set; }
}
VM:
public class FileViewModel
{
public string Title { get; set; }
public HttpPostedFileBase File { get; set; }
}
Fuente:
http://www.floatincode.net/post/sql-file-stream-in-asp.net-mvc-with-entity-framework
Podría esto ser resueltos usando un método similar http://stackoverflow.com/ preguntas/4441179/outofmemoryexception-when-using-sql-filestream? Parece estar utilizando EntityFramework mezclado con el tipo de conexión anterior. – MadBoy
sí, si no hay otra manera, usaré esto. gracias –