Call stored procedure from Entity Framework 6.1.3 code-first

c# ef-code-first entity-framework entity-framework-6

Accepted Answer

Use absentexec :

using (Model1 ent = new Models.Model1())
{
    var regionID= new SqlParameter("@RegionID", 100);
    var regionDesc= new SqlParameter("@RegionDesc", "Nima");

    ent.Database.SqlQuery<Region>("InsertRegion @RegionID ,@RegionDesc", regionID ,regionDesc);
}

Nevertheless, your SP isn't providing any recorded data, therefore you may also use this:

using (Model1 ent = new Models.Model1())
{
    var regionID= new SqlParameter("@RegionID", 100);
    var regionDesc= new SqlParameter("@RegionDesc", "Nima");

    ent.Database.ExecuteSqlCommand("InsertRegion @RegionID ,@RegionDesc", regionID ,regionDesc);
}
1
12/25/2016 4:04:17 PM


Related Questions





Related

Licensed under: CC-BY-SA with attribution
Not affiliated with Stack Overflow
Licensed under: CC-BY-SA with attribution
Not affiliated with Stack Overflow