Avatar of Peter Allen
Peter Allen
Flag for United States of America asked on

Add a Complex property to EF 6.1 Model to handle Null value


I am using Database First to design a Model for access to a database.  In the Stored Procedure I have a field that allows NULL values.  I have created the Entity Data Model as a separate Project that I can access from several applications as needed with the proper references.  When I was mapping the Stored Procedures I can't figure out exactly how to code for a field that is allowed to be null in the table.  The EF identifies the field with an extra line in the Stored Field Mapper of "@ IsNull_Table_FullDescription:int".

Here is the table "tblSupportTables" list of properties:

Field                                      Type
Table_ID                               int
Table_DateAdded              DateTime
Table_DateModified         DateTime
Table_CodeSequence      Int32
Table_RecordStatus         String
Table_Name                      String
Table_Version                   String
Table_FriendlyName       String
Table_BriefDescription   String
Table_FullDescription     String

The field "Table_FullDescription" can be NULL.  So when I mapped fields the Update and Delete Mappings added a new field. "IsNull_Table_FillDescription", with "int" as the type.

I think I have to create a new complex property?  Is this correct?  In VB.NET how would I write the code for this property?  The examples I have seen don't clearly show me so that is why I need your advice.  Thanks!
Visual Basic.NETMicrosoft SQL Server.NET ProgrammingASP.NETC#

Avatar of undefined
Last Comment
Nasir Razzaq

8/22/2022 - Mon
Nasir Razzaq

Peter Allen


Unfortunately not.  It does clearly explain the steps, but the Function Import and references to Stored procedures do exist.  What I need to do is to figure out how to handle the IsNull_Table_FullDescription property in the Stored Procedure mapper.  The field is int.

Do I just add an int property manually or some type of function?  In the Mapper I have the columns:

Use Original Value
Rows Affected Parameter

When the Stored Procedure was brought it its schema added ISNull_Table_FullDescription for the Update and Delete Stored procedures because that field can contain a null value.  Now with EntityFramework I need to map this field.  I can handle the int value when returned to the application, but wasn't quite sure if I just create a property or what....
Peter Allen


Here is the error from VisualStudio Stored Procedure Mapper:

Error 2037: A mapping function bindings specifies a function nsSupportTables.Store.stProc_SupportTablesDelete but does not map the following function parameters: IsNull_Table_FullDescription.      D:\Developement\VisualBasic 2013\ICMTS\TableEDMModels\ICMTS-SupportTablesModel\ICMTS-SupportTablesModel\SupportTablesModel.edmx      415      423      ICMTS-SupportTablesModel
Experts Exchange has (a) saved my job multiple times, (b) saved me hours, days, and even weeks of work, and often (c) makes me look like a superhero! This place is MAGIC!
Walt Forbes
Nasir Razzaq

View this solution by signing up for a free trial.
Members can start a 7-Day free trial and enjoy unlimited access to the platform.
See Pricing Options
Start Free Trial
Ask your own question & get feedback from real experts
Find out why thousands trust the EE community with their toughest problems.