zzzprojects / EntityFramework-Effort

Entity Framework Effort is a powerful tool that enables a convenient way to create automated tests for Entity Framework based applications.
https://entityframework-effort.net/
MIT License
431 stars 99 forks source link

Precision restriction not allowed on fields of type 'double' #38

Closed elliot-j closed 6 years ago

elliot-j commented 8 years ago

I have an Entity model generated from a Sybase ASE database that contains the following table

 CREATE TABLE  z_script (
    script_id                       char(30)                         not null  ,
    release_id                      char(10)                         not null  ,
    description                     char(255)                        not null  ,
    script                          text                             not null  ,
    release_num                     char(7)                          not null  ,
    sequence_num                    float(16)                        not null  ,
    before_after                    char(1)                          not null  ,
    key_prefix                      varchar(10)                          null   
)

Which generates the following into the edmx file

SSDL content

<EntityType Name="z_script">
    <Key>
        <PropertyRef Name="script_id" />
    </Key>
    <Property Name="script_id" Type="char" MaxLength="30" Nullable="false" />
    <Property Name="release_id" Type="char" MaxLength="10" Nullable="false" />
    <Property Name="description" Type="char" MaxLength="255" Nullable="false" />
    <Property Name="script" Type="text" Nullable="false" />
    <Property Name="release_num" Type="char" MaxLength="7" Nullable="false" />
    <Property Name="sequence_num" Type="float" Precision="24" Nullable="false" />
    <Property Name="before_after" Type="char" MaxLength="1" Nullable="false" />
    <Property Name="key_prefix" Type="varchar" MaxLength="10" />
</EntityType>

CSDL content

<EntityType Name="z_script">
    <Key>
        <PropertyRef Name="script_id" />
    </Key>
    <Property Name="script_id" Type="String" Nullable="false" MaxLength="30" FixedLength="true" Unicode="false" />
    <Property Name="release_id" Type="String" Nullable="false" MaxLength="10" FixedLength="true" Unicode="false" />
    <Property Name="description" Type="String" Nullable="false" MaxLength="255" FixedLength="true" Unicode="false" />
    <Property Name="script" Type="String" Nullable="false" MaxLength="Max" FixedLength="false" Unicode="false" />
    <Property Name="release_num" Type="String" Nullable="false" MaxLength="7" FixedLength="true" Unicode="false" />
    <Property Name="before_after" Type="String" Nullable="false" MaxLength="1" FixedLength="true" Unicode="false" />
    <Property Name="key_prefix" Type="String" MaxLength="10" FixedLength="false" Unicode="false" />
    <Property Name="sequence_num" Type="Double" Nullable="false" />
</EntityType>

C-S Mapping

<EntitySetMapping Name="z_script">
    <EntityTypeMapping TypeName="DxP.Services.CopathPlus.Data.z_script">
        <MappingFragment StoreEntitySet="z_script">
            <ScalarProperty Name="sequence_num" ColumnName="sequence_num" />
            <ScalarProperty Name="key_prefix" ColumnName="key_prefix" />
            <ScalarProperty Name="before_after" ColumnName="before_after" />
            <ScalarProperty Name="release_num" ColumnName="release_num" />
            <ScalarProperty Name="script" ColumnName="script" />
            <ScalarProperty Name="description" ColumnName="description" />
            <ScalarProperty Name="release_id" ColumnName="release_id" />
            <ScalarProperty Name="script_id" ColumnName="script_id" />
        </MappingFragment>
    </EntityTypeMapping>
</EntitySetMapping>

When I load the model into Effort using Effort.EntityConnectionFactory.CreateTransient(), it throws the following exception

System.Data.MetadataException: Schema specified is not valid. Errors: 
(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)   

Removing the Precision attribute from sequence_num column in the SSDL and re-running the tools for Entity does not resolve the error. The only way to get rid of the exception and get Effort to load the model is to remove the sequence_num column from the edmx model entirely.

JonathanMagnan commented 6 years ago

Hello @elliot-j ,

Is it possible for you to create a sample project with this issue?

We are currently making an issue cleanup and make sure we focus on issues people still require since it will be impossible to make them all (It's a free library!). Since that's has been a long time that this issue has been answered, it might also be already fixed.

Best Regards,

Jonathan

JonathanMagnan commented 6 years ago

Hello,

This issue will be closed since none provided information.

We understand this issue has been created long ago, but since that's a free library, we want to make sure to work on an issue that is still active since we cannot make them all.

Feel free to reopen if you can provide further information.

Best Regards,

Jonathan