I have realized that a smalldatetime sql server data type has been mapped to a datetime in my entity project. Fine with me. When the entity is saving changes it actually uses a datetime2 data type (which currently our production database doesn't support). Now, that's a problem.
我已经意识到smalldatetime sql server数据类型已映射到我的实体项目中的日期时间。我都可以。当实体保存更改时,它实际上使用datetime2数据类型(目前我们的生产数据库不支持)。现在,这是一个问题。
Looking at the entity designer code i see the property is using VB's date object although the properties window displays it as a datetime.
查看实体设计器代码,我看到该属性正在使用VB的日期对象,尽管属性窗口将其显示为日期时间。
I would rather not change the entity code as I do not want updates from the database to overwrite my changes creating a code maintenance mess.
我宁愿不更改实体代码,因为我不希望数据库中的更新覆盖我的更改,从而导致代码维护混乱。
Where did the datetime2 come from? Any ideas?
datetime2来自哪里?有任何想法吗?
Thanks in advance for any help, Orry
感谢任何帮助,Orry
2 个解决方案
#1
Ok folks, that fixed it.
好的伙计,修复了它。
Because the entity was updating refs from a sql 2008 database the ProviderManifestToken is set to 2008. Opening the edmx file in the xml editor and changing the value to 2005 fixed our problem.
因为实体正在从sql 2008数据库更新refs,所以ProviderManifestToken设置为2008.在xml编辑器中打开edmx文件并将值更改为2005修复了我们的问题。
#2
What does the SSDL say the property is?
SSDL说这个属性是什么?
Open the EDMX file up using an XML Editor (the one in VS is pretty good)
使用XML编辑器打开EDMX文件(VS中的那个很好)
Now look in the StorageModels element for the column in question.
现在查看StorageModels元素中的相关列。
The 'type' of the Property in the in the SSDL section is the type the EntityFramework thinks the database column is. I suspect it will say DateTime2. You should be able to change it back to something like DateTime.
SSDL部分中属性的“类型”是EntityFramework认为数据库列所属的类型。我怀疑它会说DateTime2。您应该能够将其更改为DateTime之类的内容。
Hope this helps
希望这可以帮助
Alex
#1
Ok folks, that fixed it.
好的伙计,修复了它。
Because the entity was updating refs from a sql 2008 database the ProviderManifestToken is set to 2008. Opening the edmx file in the xml editor and changing the value to 2005 fixed our problem.
因为实体正在从sql 2008数据库更新refs,所以ProviderManifestToken设置为2008.在xml编辑器中打开edmx文件并将值更改为2005修复了我们的问题。
#2
What does the SSDL say the property is?
SSDL说这个属性是什么?
Open the EDMX file up using an XML Editor (the one in VS is pretty good)
使用XML编辑器打开EDMX文件(VS中的那个很好)
Now look in the StorageModels element for the column in question.
现在查看StorageModels元素中的相关列。
The 'type' of the Property in the in the SSDL section is the type the EntityFramework thinks the database column is. I suspect it will say DateTime2. You should be able to change it back to something like DateTime.
SSDL部分中属性的“类型”是EntityFramework认为数据库列所属的类型。我怀疑它会说DateTime2。您应该能够将其更改为DateTime之类的内容。
Hope this helps
希望这可以帮助
Alex