开发者

Entity Framework Stored Procedure Mapping HELP!

Seems my appreciation for the Entity Framework is taking a serious hit. The "MS almost got it right, but they just missed it because of something L-A-M-E" thought is coming up. Until today everything has been fine. For some unknown reason, it won't compile anymore with Error 2048. I've read up on this and I've seen how you need to map all three operations. Why is this even necessary? What I if I don't need a delete function and only need insert and update? I tried mapping a dummy SP to my delete function. If that fixes my problem, however cheezy, fine. Only problem is, it just created more problems.

Here's what I have. I'm writing a simple newsletter app in MVC. I have entities for a publication, issue and article all generated from my DB (SQL 08). I set up the the relationships in my DB and they translated fine to my EDMX. I made some SPs to insert 开发者_StackOverflowand update my issues and article. I added them to the EDMX and mapped them accordingly. I don't need a delete function for any of them and I don't need anything for the publication entity. Why is the compiler forcing me to map all functions? IMO, this a MAJOR, MAJOR PROBLEM with EF4 and I can't believe MS would release it with this kind of crap coming up.

The other strange issue is I've tried mapping sp's to entities in another project and configured with only insert and update and they compile fine. Why is the compiler inconsistent?

I would rather not resort to having to use the Imported Functions. Is that my only option? If that's the case it eliminates the ability to the SaveChanges method. Come On MS!!! Fix this!!!!!!!


After much digging and side by side text comparison, I think I have found the solution.

The SP in question was set up like

CREATE PROCEDURE updateArticle
(
    @ArticleID INT,
    @Content TEXT
)

where it should have been something like

CREATE PROCEDURE updateArticle
( 
    @ArticleID INT,
    @IssueID INT,
    @Content TEXT
)

Now, I still don't know why EF4 even requires this since I'm not updating the issueid and the error message lends little help in diagnosing the problem. My SP doesn't even use the IssueID, but EF needs it regardless. Hopefully this will help someone down the road. MS still could do a better job regarding the need for this.

0

上一篇:

下一篇:

精彩评论

暂无评论...
验证码 换一张
取 消

最新问答

问答排行榜