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.
Thank you for the information. This really helped me
It worked like a charm. Thanks a lot bro
For me the problem was that in the body of the stored procedure the first select returning data to the user contained a value without a column name as follows:
select ‘Something…’
I added a column name and the error was gone:
select ‘Something…’ message