No mapping exists from object type System.Collections.Generic.List when executing stored proc with parameters in EF 4.3

In case someone else comes across this… I created the parameters as a List and then in the SqlQuery call I passed it with a .ToArray(). Worked for me. Here’s the modified code below… var parameters = new List<object>(); parameters.Add(new SqlParameter(“param1”, param1Value)); parameters.Add(new SqlParameter(“param2”, param2Value)); IList<XXXViewModel> XXXList = _context.Database.SqlQuery<XXXViewModel>(“spXXX @param1, @param2”, parameters.ToArray()).ToList();

Can you create sql views / stored procedure using Entity Framework 4.1 Code first approach

We support stored procedures in our Entity Framework Code First Migrations. Our approach is to create some folder to hold the .sql files (~/Sql/ for example). Create .sql files in the folder for both creating and dropping the stored procedure. E.g. Create_sp_DoSomething.sql and Drop_sp_DoSomething. Because the SQL runs in a batch and CREATE PROCEDURE.. must … Read more

One DbContext per request in ASP.NET MVC (without IOC container)

I know this is not a recent question, but I’ll post my answer anyway, because I believe someone may find it useful. As probably many others, I followed the steps mentioned in the accepted answer. Yay, it works. HOWEVER, there’s one catch: Methods BeginRequest() and EndRequest() fire each time a request is made, but not … Read more

EF Code First DBContext and Transactions

Yes. SaveChanges uses transaction internally. Use TransactionScope to wrap multiple calls to SaveChanges Example: using(var scope = new TransactionScope(TransactionScopeOption.Required, new TransactionOptions { IsolationLevel = IsolationLevel.ReadCommitted })) { // Do something context.SaveChanges(); // Do something else context.SaveChanges(); scope.Complete(); }

Hata!: SQLSTATE[HY000] [1045] Access denied for user 'divattrend_liink'@'localhost' (using password: YES)