title: How to get Web API OData v4 to use DateTime
body: <p>I have a fairly large data model that I want to expose using Web API OData using the OData V4 protocol.</p>
  
  <p>The underlying data is stored in a SQL Server 2012 database.  That database has many DateTime columns in it.</p>
  
  <p>As I was wiring it up I got an error that System.DateTime is not supported.</p>
  
  <p><strong>So here is my question, what can I do to get my DateTime columns to be seen in the OData feed?</strong></p>
  
  <p>NOTE: I am not able to go back and change all my columns to DateTimeOffset columns.</p>
  
  <p>I tried changing the type of the column in the Entity Framework edmx, but it gave me this error: </p>
  
  <blockquote>
    <p>Member Mapping specified is not valid. The type 'Edm.DateTimeOffset[Nullable=False,DefaultValue=,Precision=]' of member 'MyPropertyHere' in type 'MyProject.MyEntity' is not compatible with 'SqlServer.datetime[Nullable=False,DefaultValue=,Precision=3]' of member 'MyColumnName' in type 'MyDataModel.Store.MyEntity'.</p>
  </blockquote>
  
  <p>(Bascially syas that DateTime is not compatable with DateTimeOffset.)</p>
  
  <p>Did the Web API OData team really just leave out everyone who needs to use the SQL Server type of <code>DateTime</code>?</p>
  
  <p>Update: I have found workarounds for this, but they require updating the EF Model for them to work.  I would rather not have to update several hundred properties individually if I can avoid it.</p>
  
  <blockquote>
    <p><strong>Update:</strong> This issue has made me realize that there are deep flaws in how Microsoft is managing its OData products.  There are many issues, but this one is the most glaring.  There are huge missing features in the Web API OData.  <em><a href="http://www.getbreezenow.com/documentation/odata-server" rel="noreferrer">Transactions</a></em> and <em><a href="http://www.getbreezenow.com/documentation/odata-server" rel="noreferrer">ordering of inserts</a></em> being two of them.  These two items (that are in the OData spec and were in WCF Data Services before Microsoft killed it) are critical to any real system.  </p>
    
    <p>But rather than put time into those critical spots where they are missing functionality that is in the OData Specification, they decide to spend their time on removing functionality that was very helpful to many developers.
    It epitomizes bad management to prioritize the removal of working features over adding in badly needed features.</p>
    
    <p>I tried discussing these with the Web API OData representative, and in the end, I got a issue/ticket opened that was then closed a few days later.  That was the end of what they were willing to do.</p>
    
    <p>As I said, there are many more issues (not related to DateTime, so I will not list them here) with the management of Web API OData.  <strong>I have been a very strong supporter of OData, but the glaring issues with Web API OData's management have forced me and my team/company to abandon it.</strong></p>
    
    <p>Fortunately, normal Web API can be setup to use OData syntax.  It is more work to setup your controllers, but it works just fine in the end.  And it supports DateTime.  (And seems to have management that can at least stay away from making insanely bad decisions.)</p>
  </blockquote>