Link to home
Create AccountLog in
Avatar of Peter Allen
Peter AllenFlag 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!
Avatar of Nasir Razzaq
Nasir Razzaq
Flag of United Kingdom of Great Britain and Northern Ireland image

Avatar of 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....

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
Avatar of Nasir Razzaq
Nasir Razzaq
Flag of United Kingdom of Great Britain and Northern Ireland image

Link to home
Create an account to see this answer
Signing up is free. No credit card required.
Create Account