是否可以在edmx文件中持久添加手动添加的存储过程?数据库是从模型生成的。每次我在edmx文件的编辑器中更改某些内容时,存储过程都会丢失。之后只有FunctionImport条目仍然可用。在edmx文件中手动添加存储过程
一个示例函数如下:
<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>
相应FunctionImportMapping:
<FunctionImportMapping FunctionImportName="InsertGroup" FunctionName="DAL.Store.SP_I_InsertGroup" />
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>
你提出的或多或少是个问题。我的意思是我遵循了Microsoft在http://msdn.microsoft.com/en-us/library/dd296754.aspx上描述的步骤。这导致了所描述的问题。 – niklr
就像@Fergara所说的,当你使用设计器编辑EDMX文件时,它会重新生成它下面的所有文件。这就是你失去这些文件的原因。每次您编辑它们时,都必须重新替换这些文件。有关更多信息,请参阅下面的答案。 – Termato