Wednesday, April 22, 2020

Use stored procedures in Entity Framework Code first

This article was very helpful.

https://damianbrady.com.au/2014/12/19/calling-stored-procedures-from-entity-framework-6-code-first/

So basically, we call the stored procedure from DbContext class like so:

public virtual Customer_LoadStatus_Result Customer_LoadStatus(int? customerId)
{
    var customerIdParameter = customerId.HasValue ?
        new SqlParameter("CustomerId", customerId) :
        new SqlParameter("CustomerId", typeof(int));

    return this.Database.SqlQuery<Customer_LoadStatus_Result>("Customer_LoadStatus @customerId",
        customerIdParameter).SingleOrDefault();
}

SSL Error - The connection for this site is not secure

 After cloning a git repo of dot net framework website and trying to run it all I could see was this error Turns out the fix was to simply e...