简体   繁体   中英

Entity Framework Map Error with Stored Procedure

I am calling a SP from my C# code. Everythig worked until i wanted to change the Result Type of the SP.

Like some values from Int32 to String and some values from Double to Decimal.

Now I'm gettin this error while calling or while the mapping for the sp ist called.

German:

Die Eigenschaft 'VBENr' bei 'Report_Result' konnte nicht auf einen 'Int32'-Wert festgelegt werden. Sie müssen diese Eigenschaft auf einen Nicht-NULL-Wert des Typs 'String' festlegen.

English:

The Property 'VBENr' in 'Report_Result' could not be set to a 'Int32' value. You must set this property to a non-null value of type 'String'.

I cant do this change cause it's already what it is in the designer. I read something about the designer not working properly so i changed the Values also in the designer.cs and in *.edmx

For Example the VBENr value:

Edmx:

      <Property Type="String" Name="VBENr" Nullable="false" />

Deisgner.cs:

[EdmScalarPropertyAttribute(EntityKeyProperty=false, IsNullable=false)]
        [DataMemberAttribute()]
        public global::System.String VBENr
        {
            get
            {
                return _VBENr;
            }
            set
            {
                OnVBENrChanging(value);
                ReportPropertyChanging("VBENr");
                _VBENr = StructuralObject.SetValidValue(value, false);
                ReportPropertyChanged("VBENr");
                OnVBENrChanged();
            }
        }
        private global::System.String _VBENr;
        partial void OnVBENrChanging(global::System.String value);
        partial void OnVBENrChanged();

Really dont know why i gettin this error message..

Thank you

Markus

Sometimes the code generator will not accept/refresh your changes. When that happens to me, I follow this steps:

  1. Delete the table from the edmx
  2. Save the .edmx
  3. Add the table (Update Model from Database)
  4. Save the .edmx
  5. Run the t4 scripts by myself (right click the .tt file, hit Run Custom Tool)

Don't edit the generated code because the next time you modify and save the .edmx your changes will be lost.

The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM