Warning: file_get_contents(/data/phpspider/zhask/data//catemap/7/sql-server/22.json): failed to open stream: No such file or directory in /data/phpspider/zhask/libs/function.php on line 167

Warning: Invalid argument supplied for foreach() in /data/phpspider/zhask/libs/tag.function.php on line 1116

Notice: Undefined index: in /data/phpspider/zhask/libs/function.php on line 180

Warning: array_chunk() expects parameter 1 to be array, null given in /data/phpspider/zhask/libs/function.php on line 181
C# 托管实体框架不生成存储过程映射_C#_Sql Server_Visual Studio 2010_Stored Procedures - Fatal编程技术网

C# 托管实体框架不生成存储过程映射

C# 托管实体框架不生成存储过程映射,c#,sql-server,visual-studio-2010,stored-procedures,C#,Sql Server,Visual Studio 2010,Stored Procedures,请注意,我试图使用存储过程来插入和更新表记录。当我将存储过程添加到数据库并更新*.edmx文件时,它会看到我添加的存储过程;但是,我之前在另一个项目中做了以下工作: var db = new MyMarinaEntities(); db.prBoatInsert(registrationNumber, manufacturer, modelYear, length, customerID); 但是现在,当我键入“db”时,intellisense没有看到插入存储过程。另外,当我在InlandM

请注意,我试图使用存储过程来插入和更新表记录。当我将存储过程添加到数据库并更新*.edmx文件时,它会看到我添加的存储过程;但是,我之前在另一个项目中做了以下工作:

var db = new MyMarinaEntities();
db.prBoatInsert(registrationNumber, manufacturer, modelYear, length, customerID);
但是现在,当我键入“db”时,intellisense没有看到插入存储过程。另外,当我在InlandMarinaEntities.Designer.cs文件中搜索时,它没有任何

public int prBoatUpdate(Nullable<global::System.Int32> boatID, global::System.String registrationNumber, global::System.String manufacturer, Nullable<global::System.Int32> modelYear, Nullable<global::System.Int32> length, Nullable<global::System.Int32> customerID) 
public int-prBoatUpdate(可空的boatID,全局::System.String注册号,全局::System.String制造商,可空的modelYear,可空的长度,可空的customerID)
功能。有人知道为什么不将prBoatUpdate添加到*.Designer.cs文件吗


或者,我知道MEF可以为每个表生成插入、更新和删除操作;但是,在生成*.edmx文件时,我看不到添加了任何这些操作,也看不到在通过向导生成*.edmx文件时添加这些操作的任何选项。我错过了什么?请注意,我使用的是Visual Studio 2010和SQL Server 2008。TIA。

请注意,我决定如何使用MEF自动生成的函数而不是使用存储过程来添加和更新数据库项。以下是如何从数据库加载对象:

private void LoadBoat(int boatID)
{
    using (var db = new MyMarinaEntities())
    {
        var boat = db.Boats.SingleOrDefault(b => (b.BoatID == boatID));

        this.chkIsRental.Checked = boat.IsRental;
        this.chkInactive.Checked = boat.Inactive;
        this.txtLength.Text = boat.Length;
        this.txtManufacturer = boat.Manufacturer;
        // ...
    }
}
以下是如何保存对船的更改:

protected void btnSave_click(object sender, EventArgs args)
{
    using (var dm = new MyMarinaEntities())
    {
        MyMarinaEntities boat;

        boat.IsRental = this.chkIsRental.Checked;
        boat.Inactive = this.chkInactive.Checked;
        boat.Length = this.txtLength.Text;
        boat.Manufacturer = this.txtManufacturer;
        // ...
        if (boatID.Value == "") 
            dm.AddObject("Boats", boat);
        dm.SaveChanges();
    }
}

因此,MEF不仅可以避免为对象关系映射(ORM)编写大量代码,还可以避免为存储过程或命令编写SQL代码。

MEF是托管可扩展性框架