Effort Framework无法识别实体模型架构

本文关键字:实体模型 识别 Framework Effort | 更新日期: 2023-09-27 18:25:57

我有一个Sybase ASE数据库的实体模型,我正在尝试使用Effort Framework为其创建单元测试。我可以在我的主项目和单元测试项目中使用实体模型访问数据库,但当尝试使用Effet创建内存中数据库时,我会遇到异常。

单元测试项目中的问题代码

public SetUpShims()
{
     string connString = System.Configuration.ConfigurationManager.ConnectionStrings["CoPathDataContext"].ConnectionString;
     MyDbContext context;
     // CreateTransient throws exception
     EntityConnection conn = Effort.EntityConnectionFactory.CreateTransient(connString);
     context = new Data.CoPathDataContext(conn);
}

异常详细信息:(System.Data.MetadataException)

Schema specified is not valid. Errors: 
(0,0) : error 0063: Precision facet isn't allowed for properties of type double.
(0,0) : error 0063: Precision facet isn't allowed for properties of type double.
(0,0) : error 0063: Precision facet isn't allowed for properties of type double.
(0,0) : error 0063: Precision facet isn't allowed for properties of type double.
(0,0) : error 0063: Precision facet isn't allowed for properties of type double.
(0,0) : error 0063: Precision facet isn't allowed for properties of type double.
(0,0) : error 0063: Precision facet isn't allowed for properties of type double.
(0,0) : error 0063: Precision facet isn't allowed for properties of type double.
(0,0) : error 0063: Precision facet isn't allowed for properties of type double.
(0,0) : error 0063: Precision facet isn't allowed for properties of type double.
(0,0) : error 0063: Precision facet isn't allowed for properties of type double.

堆栈跟踪

at System.Data.Metadata.Edm.StoreItemCollection.Loader.ThrowOnNonWarningErrors()  
at System.Data.Metadata.Edm.StoreItemCollection.Loader.LoadItems(IEnumerable`1 xmlReaders, IEnumerable`1 sourceFilePaths) 
at System.Data.Metadata.Edm.StoreItemCollection.Loader..ctor(IEnumerable`1 xmlReaders, IEnumerable`1 sourceFilePaths, Boolean throwOnError)  
at System.Data.Metadata.Edm.StoreItemCollection.Init(IEnumerable`1 xmlReaders, IEnumerable`1 filePaths, Boolean throwOnError, DbProviderManifest& providerManifest, DbProviderFactory& providerFactory, String& providerManifestToken, Memoizer`2& cachedCTypeFunction)
at System.Data.Metadata.Edm.StoreItemCollection..ctor(IEnumerable`1 xmlReaders)   
at Effort.Internal.Common.MetadataWorkspaceHelper.CreateMetadataWorkspace(List`1 csdl, List`1 ssdl, List`1 msl)   
at Effort.Internal.Common.MetadataWorkspaceHelper.Rewrite(String metadata, String providerInvariantName, String providerManifestToken) 
at Effort.EntityConnectionFactory.<GetEffortCompatibleMetadataWorkspace>b__1(String metadata)
at Effort.Internal.Caching.MetadataWorkspaceStore.<>c__DisplayClass1.<GetMetadataWorkspace>b__0()
at System.Lazy`1.CreateValue()   
at System.Lazy`1.LazyInitValue()
at System.Lazy`1.get_Value()
at Effort.Internal.Caching.ConcurrentCache`2.Get(TKey key, Func`1 factory)  
at Effort.Internal.Caching.MetadataWorkspaceStore.GetMetadataWorkspace(String metadata, Func 2 workspaceFactoryMethod)
at Effort.EntityConnectionFactory.GetEffortCompatibleMetadataWorkspace(String& entityConnectionString)
at Effort.EntityConnectionFactory.CreateTransient(String entityConnectionString, IDataLoader dataLoader)
at Effort.EntityConnectionFactory.CreateTransient(String entityConnectionString)   

在查看了Entity制作的.csdl和.ssdl文件后,我相信我找到了导致问题的字段。

SSDL

<Property Name="sequence_num" Type="float" Precision="24" Nullable="false" />

CSDL

<Property Name="sequence_num" Type="Double" Nullable="false" />

我尝试从SSDL字段中删除Precision属性,但仍然收到相同的错误。(即使它确实有效,当模型重新生成时,更改可能也不会持续)

有人想知道是什么导致了异常,以及我应该如何解决它吗?

Effort Framework无法识别实体模型架构

如果您还没有这样做,请将MySQL服务器升级到5.6+,然后更新您的所有日期、日期时间、时间。。。。。。带有选项的0-6英寸()