Using SQL Server 2008 and SQL Server 2005 and date time

前端 未结 8 2179
春和景丽
春和景丽 2020-12-12 12:52

I\'ve built a entity framework model against a 2008 database. All works ok against the 2008 database. When I try to update the entity on a 2005 database I get this error.

相关标签:
8条回答
  • 2020-12-12 13:37

    Better solution to me is instead of manually editing EDMX file is just open edmx in design mode and in context menu "Update Model from Database...". You have to be pointing to right SQL version of course whatever this is for you.

    0 讨论(0)
  • 2020-12-12 13:39

    Had a similar problem with 2012 vs. 2008. It can be solved with a BeforeBuild event using XmlPeek and XmlPoke:

       <Target Name="BeforeBuild">
          <XmlPeek XmlInputPath="$(ProjectDir)MyModel.edmx"
                   Namespaces="&lt;Namespace Prefix='edmx' Uri='http://schemas.microsoft.com/ado/2009/11/edmx'/&gt;&lt;Namespace Prefix='ssdl' Uri='http://schemas.microsoft.com/ado/2009/11/edm/ssdl'/&gt;"
                   Query="/edmx:Edmx/edmx:Runtime/edmx:StorageModels/ssdl:Schema/@ProviderManifestToken">
             <Output TaskParameter="Result" ItemName="TargetedSQLVersion" />
          </XmlPeek>
    
          <XmlPoke Condition="@(TargetedSQLVersion) != 2008"
                   XmlInputPath="$(ProjectDir)MyModel.edmx"
                   Namespaces="&lt;Namespace Prefix='edmx' Uri='http://schemas.microsoft.com/ado/2009/11/edmx'/&gt;&lt;Namespace Prefix='ssdl' Uri='http://schemas.microsoft.com/ado/2009/11/edm/ssdl'/&gt;"
                   Query="/edmx:Edmx/edmx:Runtime/edmx:StorageModels/ssdl:Schema/@ProviderManifestToken"
                   Value="2008">
          </XmlPoke>
       </Target>
    

    If you dislike automated replacement, you can simply replace the XmlPoke task with an Error task.

    0 讨论(0)
提交回复
热议问题