X

Identifier is null or empty error when adding stored procedure in entity framework data model

You can add database tables and stored procedures in your Entity Framework data model, but you may encounter an ArgumentException error in Visual Studio when adding a stored procedure:

An exception of type ‘System.ArgumentException’ occurred while attempting to update from the database. The exception message is: ‘Identifier is null or empty’

The error message is confusing because the actual cause of this error is that the stored procedure does not have a return value. In order to add a stored procedure in EF data model, EF will first try to execute the stored procedure in a special environment (so it will not mess up your database), and if there is no return value in the stored procedure, EF will think there is something wrong with the stored procedure and throw the above exception error. So to fix this error, just make sure your stored procedure returns something, it can be really anything. For instance, I modified my stored procedure to include an OUTPUT parameter indicating if the execution is successful and the EF data model happily added the stored procedure without any exception error.

Hope this helps.

0 0 votes
Article Rating
Jeffrey:
Related Post