Click here to Skip to main content
15,867,594 members
Please Sign up or sign in to vote.
0.00/5 (No votes)
See more: , +
Hi all,
I'm having a little trouble with using some Stored Procedures in an Entity Framework 4.0 model. I'm using Visual Studio 2010 and .NET/EF 4.0 and I have a SQL Server 2008 database.

So in my database I have a couple of SP's;
A1.MySP
B1.MySP
B2.MySP

You might guess the problem, the SP's are all named the same. For the database this is no problem because they are in different schema's. For the Entity Framework this IS a problem though (even though it knows the schema, it doesn't use it!)...

So I add B1.MySP to the model and I create a function imports, works like a charm.
I add B2.MySP to the model, it creates a function MySP1 and everything still works fine.
Then I add A1.MySP to the model and this is when stuff gets weird... A1 comes before B1 so the A1.MySP gets called MySP in the model. B1.MySP used to be MySP, but gets renamed to MySP1 and B2.MySP gets renamed to MySP2. But I already had function imports for those SP's! Well, they don't work that wel anymore and I have to recreate them...

The database is pretty full with this kind of naming convention and changing it might be a problem. Is there a workaround for this problem? I searched on Google, but I couldn't find anything that could help me...

Thanks.
Posted
Comments
johannesnestler 8-Oct-14 5:32am    
I'm not shure if I fully understand, but if I remember right (EF4) you can call the SP's whatever you want in the model - just don't rely on the default.
Sander Rossel 8-Oct-14 5:46am    
Yeah, you can, but in the underlying edmx file the function names get changed causing your (self-named) function imports to lose their mappings.
[no name] 8-Oct-14 6:38am    
Only way is use proper names for Functions try to give MySP_A
Sander Rossel 8-Oct-14 7:10am    
Yeah, we didn't want to do that because we already have about 30 SP's with those kind of names... So changing that would mean we'd have to change other SP's and software too.
Venkatesh Mookkan 13-Oct-14 4:04am    
Add another EF file for another DB. You will have problem, only if you try to add the other DB's SPs in the same EF file

This content, along with any associated source code and files, is licensed under The Code Project Open License (CPOL)



CodeProject, 20 Bay Street, 11th Floor Toronto, Ontario, Canada M5J 2N8 +1 (416) 849-8900