Last post Jul 15, 2015 01:05 AM by Ndra13
Jul 14, 2015 01:21 AM|Ndra13|LINK
I have DBMarket with 3 table (Ms Item, Transaction, DetailTransaction) and stored procedures to view, insert, update and delete to each table.
I use SQL Server express and i want my application to use that store procedure for some reason (Not use LocalDB on apps).
I already read EF Database first with ASP.NET MVC tutorial and Async and Stored Procedures with the Entity Framework in an ASP.NET MVC Application
I follow the instruction, Use async controller action and adding :
on protected override void OnModelCreating(DbModelBuilder modelBuilder) (on EDMX)
I try to insert on MsItem and it's not using my stored procedure.
Please help me for some advice or tutorial link, thanks.
Jul 14, 2015 01:40 AM|mostafasydney|LINK
Are you getting any error message?
Can you debug to the point where it is not working?
Jul 14, 2015 02:10 AM|Ndra13|LINK
There's no error, i get success insert data to my DB but it's not use the storeprocedure.
I set static value to note column from my stored procedure and the value inserted not have that static value.
So i think my stored procedure is not execute by my apps.
Jul 14, 2015 02:14 AM|mostafasydney|LINK
Check your SP working correct and you are calling in right way.
Jul 14, 2015 03:36 AM|Ndra13|LINK
I think there's no error in my SP, I execute MsItem_Insert manually and have my data stored to my DB.
Is it possible the tutorial is only work for code first?
Please give me solution or advice.
Thank you, Mostafa.
Jul 14, 2015 04:20 AM|mostafasydney|LINK
In think you are using the sample for database-first, but you can follow this one: http://www.asp.net/mvc/overview/getting-started/getting-started-with-ef-using-mvc/async-and-stored-procedures-with-the-entity-framework-in-an-asp-net-mvc-application
for code first approach with stored procedure. Except this one uses Async methods which you will need to consider.
Hope this will help.
Jul 14, 2015 11:33 PM|Ndra13|LINK
I already read some article and start over new application but still no solution.
I already add :
protected override void OnModelCreating(DbModelBuilder modelBuilder)
s => s.Insert(i => i.HasName("[dbo].[SpMsItem_Insert]"))
.Update(u => u.HasName("[dbo].[SpMsItem_Update]"))
.Delete(d => d.HasName("[dbo].[SpMsItem_Delete]"))
throw new UnintentionalCodeFirstException();
to specify using stored procedure with determined name for insert, update and delete.
I found that my application not using the stored procedure I created for insert, update and delete action.
Please somebody help me...
Jul 15, 2015 01:05 AM|Ndra13|LINK
Finally I found the solution, from this link :
That's tutorial for web forms with EF4 and maybe there's simpler or other way with MVC with EF6.