Vic F
Vic F

Reputation: 1459

Error updating EDMX file

I've seen some other posts about this, but none of the answers seem to help. I'm trying to add a stored procedure to an EDMX. I open the diagram, right-mouse-click, and choose "Update Model from Database." I choose "Yes" for including sensitive data and I uncheck the "Save connection settings in App.config." (This EDMX is inside a class library that's sole purpose is housing this EDMX). I click Next, and choose the "Add" tab. I expand "Stored Procedures and Functions" and then find and click the checkbox for my stored proc. I only check the "Import selected stored procedures and functions into the entity model" and click "Finish." The error I receive is:

An exception of type 'System.ArgumentException' occurred while attempting to update from the database. The exception message is 'Identifier is null or empty!".

I save the diagram. I search the entire solution for the name of my proc, and it only exists in the code that is trying to call it - there is no instance inside the EDMX.

The stored proc definition looks like this:

ALTER Procedure [dbo].[spGetCountableResult]
    @PatientId BIGINT
AS 

My connection string looks like this:

<add name="DB_Entities" connectionString="metadata=res://*/Models.DBContext.csdl|res://*/Models.DBContext.ssdl|res://*/Models.DBContext.msl;provider=System.Data.SqlClient;provider connection string=&quot;data source=DB.com;initial catalog=MyDb;user id=MyUser;password=MyPassword;multipleactiveresultsets=True;application name=EntityFramework&quot;" providerName="System.Data.EntityClient" />

My package.config entry is:

<package id="EntityFramework" version="6.1.3" targetFramework="net45" />

Anyone know what's going wrong here?

V

Upvotes: 4

Views: 6864

Answers (5)

jim.gray
jim.gray

Reputation: 31

I had the same issue and after narrowing down which sproc was causing the issue, I realized I had some nested procedures in my failing procedure. I commented out the nested procedures, updated the model, then uncommented them later.

This wasn't a permanent solution, but it 'works in a pinch'.

Upvotes: 1

Jag
Jag

Reputation: 75

Try not to use stored procedure with #user or ##global temp tables. if you are unable to escape, try with output parameter or return explicit 0.

Upvotes: 0

imPrajeshTrivedi
imPrajeshTrivedi

Reputation: 1

If you have Error while adding a stored procedure to an EDMX : An exception of type System.ArgumentException occurred while attempting to update from the database. The exception message is "Identifier is null or empty!".

Then you can add just set FMTONLY off in stored procedure

BEGIN
    Set FMTONLY off;
END

Upvotes: -1

SIbghat
SIbghat

Reputation: 309

After pending hours I found the solution

There must be some SP with IF EXISTS or related check on some entity which is not present e.g some #tempTable etc.

Make sure that all the objects are available for EF even with NULL values then execute it will work.

For me it was one out of 200+ SPs causing all the trouble.

Upvotes: 0

Eduardo de Souza Cruz
Eduardo de Souza Cruz

Reputation: 133

The problem is probably that your procedure performs SELECTs without naming all the columns.

See this: http://entityframework.codeplex.com/workitem/1529

If you procedure has something like SELECT 1, you will get the "Identifier is null or empty!" error. But if it was SELECT 1 as 'One' then it should work.

Upvotes: 4

Related Questions