7
I would like to know how to map an attribute of the type image of SqlServer by the Fluent API.
In my bank I have the following table:
CREATE TABLE [dbo].[ProdutoFotoERP](
[ProdutoFotoID] [int] NOT NULL,
[ProdutoID] [int] NOT NULL,
[Foto] [image] NULL,
CONSTRAINT [PK_ProdutosFotoERP] PRIMARY KEY CLUSTERED
(
[ProdutoFotoID] ASC
))
And I created my entity as follows:
public class ProdutoFotoERP
{
public int ProdutoFotoID { get; set; }
public int ProdutoID { get; set; }
public byte[] Foto { get; set; }
public virtual ProdutoERP ProdutoERP { get; set; }
}
At first my configuration class is like this:
public class ProdutoFotoERPConfiguration : EntityTypeConfiguration<ProdutoFotoERP>
{
public ProdutoFotoERPConfiguration()
{
ToTable("ProdutoFotoERP");
HasKey(c => c.ProdutoFotoID);
Property(c => c.ProdutoFotoID).HasDatabaseGeneratedOption(DatabaseGeneratedOption.None);
}
}
Dude, the guy
imageis deprecated and will be removed in the next versions of SQL Server. If you are starting the system now, you better usevarbinary(max).– Jéf Bueno
Unfortunately it is a legacy system and I am making improvements to it, if I could, even image would not write to the database, only the path from where it is.
– Jeferson Almeida
Managed to solve?
– Jéf Bueno
@jbueno just tested and worked perfectly, thank you very much
– Jeferson Almeida