MVC3 - 将存储过程添加到模型中

发布于 2024-11-09 03:47:30 字数 877 浏览 3 评论 0原文

我创建存储过程:

CREATE PROCEDURE  dbo.GetCampaigns  
    @UserID varchar(15) 
AS

BEGIN
    -- SET NOCOUNT ON added to prevent extra result sets from
    -- interfering with SELECT statements.
    SET NOCOUNT ON;

    SELECT CampaignId, CampaignName,  Expiry, LaunchDate FROM feeds.dbo.Campaigns  WHERE userid=@UserID;

END

返回的campaignId 是一个唯一的键。

我将其拖放到 serverExplorer 中。我构建它并创建模型。我右键单击控制器来创建控制器、数据上下文等。它会弹出一个带有消息的框:

Unable to retrieve metadaat for xxx.Models.CampaignResult. One or more validation errors were detected during model generation:
-System Data.Edm.EdmEntitytype: Entity Type getCampaingsResult has no key defined. Define a key for this entity type
-System.Data.Edm.EdmEntitySet: EntityType: EntitySet GetCampaignResults is based on type GetCampaignResult that has no keys defined.

我很困惑。提前致谢。任何帮助表示赞赏。

I create the stored proc:

CREATE PROCEDURE  dbo.GetCampaigns  
    @UserID varchar(15) 
AS

BEGIN
    -- SET NOCOUNT ON added to prevent extra result sets from
    -- interfering with SELECT statements.
    SET NOCOUNT ON;

    SELECT CampaignId, CampaignName,  Expiry, LaunchDate FROM feeds.dbo.Campaigns  WHERE userid=@UserID;

END

The campaignId in the return is a unique key.

I drag and drop this into serverExplorer. I build it and it creates the Model. I right click on controller to create the controller, data context etc. It pops up a box with the message:

Unable to retrieve metadaat for xxx.Models.CampaignResult. One or more validation errors were detected during model generation:
-System Data.Edm.EdmEntitytype: Entity Type getCampaingsResult has no key defined. Define a key for this entity type
-System.Data.Edm.EdmEntitySet: EntityType: EntitySet GetCampaignResults is based on type GetCampaignResult that has no keys defined.

I'm confused. Thanks in advance. Any help appreciated.

如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。

扫码二维码加入Web技术交流群

发布评论

需要 登录 才能够评论, 你可以免费 注册 一个本站的账号。
我们使用 Cookies 和其他技术来定制您的体验包括您的登录状态等。通过阅读我们的 隐私政策 了解更多相关信息。 单击 接受 或继续使用网站,即表示您同意使用 Cookies 和您的相关数据。
原文