Entity Framework stored procedure question

P

Paul Speranza

I am new at this so please bear with me.

I have a table called ApplicationUser which mapped fine into EF and I can
insert using my CreateUser proc. I have another proc called GetUserByName and
I imported that to a function so in my code I can do this :

ObjectResult<ApplicationUser> query =
context.GetUserByUserName(userName);
ApplicationUser user = query.ToList().First();

I have another proc called SetLoginAttempts(id, attempts). I have done the
same import but it will not show up as a method of context. Any ideas as to
what I am doing wrong?

Thanks
 
M

Mary Chipman [MSFT]

I asked Brian Swan for help with your question, and here's his
response. HTH, --Mary

Unfortunately, when a FunctionImport is created from a stored
procedure that does not return an entity type, no code is
automatically generated for the FunctionImport. This is why you are
not seeing SetLoginAttempts show up as a method on the ObjectContext
(assuming SetLoginAttempts doesn't map to an entity type). The Entity
Framework team is working to improve this scenario going forward.
There is good information in this forum post about how to work around
the issue for now:
http://forums.microsoft.com/MSDN/ShowPost.aspx?PostID=2643093&SiteID=1.

For information about tools-supported scenarios with stored
procedures, see "Walkthrough: Mapping an Entity to Stored Procedures"
http://msdn.microsoft.com/en-us/library/cc716679.aspx and
"Walkthrough: Retrieving Entity Types with a Stored Procedure"
http://msdn.microsoft.com/en-us/library/cc716672.aspx.

--Brian Swan, Microsoft
Entity Data Model Videos
http://msdn.microsoft.com/en-us/data/cc300162.aspx#entity
 

Ask a Question

Want to reply to this thread or ask your own question?

You'll need to choose a username for the site, which only take a couple of moments. After that, you can post your question and our members will help you out.

Ask a Question

Top