Sign Up

Sign Up to our social questions and Answers Engine to ask questions, answer people’s questions, and connect with other people.

Have an account? Sign In

Have an account? Sign In Now

Sign In

Login to our social questions & Answers Engine to ask questions answer people’s questions & connect with other people.

Sign Up Here

Forgot Password?

Don't have account, Sign Up Here

Forgot Password

Lost your password? Please enter your email address. You will receive a link and will create a new password via email.

Have an account? Sign In Now

You must login to ask a question.

Forgot Password?

Need An Account, Sign Up Here

Please briefly explain why you feel this question should be reported.

Please briefly explain why you feel this answer should be reported.

Please briefly explain why you feel this user should be reported.

Sign InSign Up

The Archive Base

The Archive Base Logo The Archive Base Logo

The Archive Base Navigation

  • SEARCH
  • Home
  • About Us
  • Blog
  • Contact Us
Search
Ask A Question

Mobile menu

Close
Ask a Question
  • Home
  • Add group
  • Groups page
  • Feed
  • User Profile
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Buy Points
  • Users
  • Help
  • Buy Theme
  • SEARCH
Home/ Questions/Q 7028619
In Process

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: May 28, 20262026-05-28T00:26:01+00:00 2026-05-28T00:26:01+00:00

I have a POCO class called Attachment that maps to a table in SqlServer

  • 0

I have a POCO class called Attachment that maps to a table in SqlServer with a VarBinary(max) field in it. The field contains files.

The POCO class looks like this

public class Attachment
{
    public string AttachmentId { get; set; }
    public string AttachmentTypeId { get; set; }
    public string Title { get; set; }
    public string Text { get; set; }
    public Binary Data { get; set; }
}

The Mapping looks like this

modelBuilder.Entity<Attachment>().Property(a => a.Data).HasColumnName("col_data");

However the mapping is throwing an error

The type 'System.Date.Linq.Binary' must be a non-nullable value type in order to use it as a parameter 'T'

The mapping works fine if I use a byte array but this seems to be corrupting the data on the way through.

The file in the database has an initial binary string like:-

0x504B0304140008000800027923400000000000000000000000001F000000

I think this is a JPG file.
Any help getting the file out of the DB in one piece would be appreciated.

  • 1 1 Answer
  • 0 Views
  • 0 Followers
  • 0
Share
  • Facebook
  • Report

Leave an answer
Cancel reply

You must login to add an answer.

Forgot Password?

Need An Account, Sign Up Here

1 Answer

  • Voted
  • Oldest
  • Recent
  • Random
  1. Editorial Team
    Editorial Team
    2026-05-28T00:26:02+00:00Added an answer on May 28, 2026 at 12:26 am

    Binary data type is only for Linq-to-Sql. EF is not able to work with it. The correct data type for EF is byte array (byte[]).

    • 0
    • Reply
    • Share
      Share
      • Share on Facebook
      • Share on Twitter
      • Share on LinkedIn
      • Share on WhatsApp
      • Report

Sidebar

Related Questions

I have a simple POCO class that contains the student's scores. For example: Math
I have a POCO class, mapping to a table that basically contain three primary
I have a serializable POCO called DataUnification.ClientData.ClientInfo in a .NET class library project A
I have a POCO class that is being sent to the browser as a
I have an Entity Framework POCO class that is generated by a T4 Template.
I have a class that is designed primarily as a POCO class, with various
Say I have a POCO that stores a date range as follows: public class
I have created a model POCO class called Recipe ; a corresponding RecipeRepository persists
I have a simply Class that is intended to be a simple POCO -
In my POCO class I have 16 attributes that are mapped to the database

Explore

  • Home
  • Add group
  • Groups page
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Users
  • Help
  • SEARCH

Footer

© 2021 The Archive Base. All Rights Reserved
With Love by The Archive Base

Insert/edit link

Enter the destination URL

Or link to existing content

    No search term specified. Showing recent items. Search or use up and down arrow keys to select an item.