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 897493
In Process

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: May 15, 20262026-05-15T14:53:44+00:00 2026-05-15T14:53:44+00:00

Entity framework maps DB types to .NET types, for instance SQL Server’s BigInt is

  • 0

Entity framework maps DB types to .NET types, for instance SQL Server’s BigInt is mapped to .NET’s long.

Is it possible to create a new type and have a store type (such as BigInt or VarChar) mapped to it? If so, how?

FYI, my goal is to change the way the .NET scalar writes its value to the query, and specifically the way its default value is written (I’m trying to use SQL Server’s default keyword to solve problem such as this).

Thanks,
Asaf

Update
Found a post for EF 1 saying it can’t be done. I’m not sure it’s correct for its time, and I’m even less sure it’s relevant for EF 4.

  • 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-15T14:53:45+00:00Added an answer on May 15, 2026 at 2:53 pm

    I’m almost sure you can’t create new scalar types even in EF4.0.

    What you actually can do is to create a Complex type wrapping underlying scalar type. Complex types are supported by designer in VS2010.

    <ComplexType Name="DateTimeWrapper" >
      <Property Type="DateTime" Name="Value" Nullable="false" />
    </ComplexType>
    

    Provide any default value you want and a couple of implicit conversion operators.

    public class DateTimeWrapper
        {
            private DateTime _value = DateTime.Now;
    
            public DateTime Value
            {
                get { return _value; }
                set { _value = value; }
            }
    
            public static implicit operator DateTime(DateTimeWrapper wrapper)
            {
                if (wrapper == null) return DateTime.Now;
                return wrapper.Value;
            }
    
            public static implicit operator DateTimeWrapper(DateTime date)
            {
                return new DateTimeWrapper { Value = date };
            }
        }
    

    So every entity having complex property of DateTimeWrapper type will be correctly initialized. And you can use syntax like this: MyEntity.MyDateTimeWrapperProp = DateTime.UtcNow when creating and modifying entities.

    But in queries you’ll have to write MyEntities.Where(ent => ent.MyDateTimeWrapperProp.Value == ...).

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

Sidebar

Ask A Question

Stats

  • Questions 513k
  • Answers 513k
  • Best Answers 0
  • User 1
  • Popular
  • Answers
  • Editorial Team

    How to approach applying for a job at a company ...

    • 7 Answers
  • Editorial Team

    What is a programmer’s life like?

    • 5 Answers
  • Editorial Team

    How to handle personal stress caused by utterly incompetent and ...

    • 5 Answers
  • Editorial Team
    Editorial Team added an answer The spec for Title column is incorrect, as well as… May 16, 2026 at 5:59 pm
  • Editorial Team
    Editorial Team added an answer I would say definitely be careful of memory leaks, especially… May 16, 2026 at 5:59 pm
  • Editorial Team
    Editorial Team added an answer You should be using .xib files and not .nib From… May 16, 2026 at 5:59 pm

Trending Tags

analytics british company computer developers django employee employer english facebook french google interview javascript language life php programmer programs salary

Top Members

Related Questions

I am writing a new application using the Entity Framework. Where would the EF
Entity Framework 4, POCO objects and ASP.Net MVC2. I have a many to many
This is entity framework 4. CurrentProperty.FMVHistories.Add(FMVPresenter.GetFMVHistoryObject()); DataLayer.AccrualTrackingEntities repository = new AccrualTrackingEntities(); repository.Properties.AddObject(CurrentProperty); repository.SaveChanges(); Right
This is for Entity Framework for .NET 3.5: I have the need to query
I'm using .NET 4 and the Entity Framework to construct a simple query. Here's
I'm creating a WCF service that transfers entity objects created via entity framework. I
I remember reading once (I believe the book was the .NET Framework Design Guidelines)
Entity framework provides great flexibility to update data in the same datacontext Dim personA
Entity Framework magically interprets the following table structure as a many-to-many relationship. table foo
I have just started Entity Framework & linq and write this query var query

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.