在edmx文件中手动添加存储过程

nik*_*klr 5 c# stored-procedures edmx

是否可以在edmx文件中持久添加手动添加的存储过程?数据库是从模型生成的.每次我在edmx文件中的编辑器中更改某些内容时,存储过程都会丢失.之后只有FunctionImport条目可用.

示例函数如下所示:

<Function Name="SP_I_InsertGroup" Aggregate="false" BuiltIn="false" NiladicFunction="false" IsComposable="false" ParameterTypeSemantics="AllowImplicitConversion" Schema="dbo">
    <Parameter Name="name" Type="nvarchar" Mode="In" />
    <Parameter Name="chiefId" Type="int" Mode="In" />
    <Parameter Name="description" Type="nvarchar" Mode="In" />
    <Parameter Name="parentId" Type="int" Mode="In" />
    <Parameter Name="mode" Type="char" Mode="In" />
</Function>
Run Code Online (Sandbox Code Playgroud)

相应的FunctionImportMapping:

<FunctionImportMapping FunctionImportName="InsertGroup" FunctionName="DAL.Store.SP_I_InsertGroup" />
Run Code Online (Sandbox Code Playgroud)

FunctionImport:

<FunctionImport Name="InsertGroup" ReturnType="Collection(Int32)">
    <Parameter Name="name" Mode="In" Type="String" />
    <Parameter Name="chiefId" Mode="In" Type="Int32" />
    <Parameter Name="description" Mode="In" Type="String" />
    <Parameter Name="parentId" Mode="In" Type="Int32" />
    <Parameter Name="mode" Mode="In" Type="String" />
</FunctionImport>
Run Code Online (Sandbox Code Playgroud)

Fer*_*ara 2

Moo,您不应该手动修改 edmx 文件。

\n\n

“对此文件的更改可能会导致不正确的行为,并且如果重新生成代码,该文件将会丢失。”

\n\n

这就是你失去工作的原因。您应该映射设计器中已创建的存储过程,就像使用表进行映射一样。

\n\n

我\xc2\xb4m 假设你\xc2\xb4 正在玩EF4。

\n