0

We're working with Entity Framework 4 but we're being told the database to use is SQL Server 2005 even though we seem to have licenses for 2008R2. Notably, SQL Server 2005 seems to be missing a 'date' type, which has been requested in the requirements.

For the purposes of keeping the rest of the application the same in case we move to SQL Server 2008R2 later, is there some way to semi-automatically treat a datetime type as a date in the rest of the application via Entity Framework 4?

1 Answer 1

2

I use SQL SERVER 2008R2 and date type. It is easly mapped to DateTime in Entity Framework 4. So there will be no problem in any case.

Sign up to request clarification or add additional context in comments.

4 Comments

I'd like to but in the question I noted that for now we're being forced to go with SQL Server 2005 which LACKS a date type. I want to do something, ideally at the framework level (and automatically), which does the conversion in and out so the rest of the codebase can think its working with a date when it's really being stored as a datetime in SQL Server. I'm willing to do it at a slightly higher level myself but I was hoping to see if there's a direct feature in Entity Framework for this.
Ok. But in application you use DateTime. Am I right? Changing mapping in EF from DateTime -> DateTime to Date->DateTime makes no problem. I don't know if I understand your problem. Automatically means without compile code? If yes I think there is no such an option.
Other way around. Want to use Date in application but datetime on the database (since it won't support date).
I can't even find Date type in C# and also seems that EF doesn't support it. I highly recommend you to use date time and then format it to date on visual side of application.

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Start asking to get answers

Find the answer to your question by asking.

Ask question

Explore related questions

See similar questions with these tags.