Nếu bạn dùng Entity Framework và generate file edmx from db, khi publish website lên host gặp lỗi:
"The context is being used in Code First mode with code that was generated from an EDMX file for either Database First or Model First development..."
thì cách fix như sau:
1. Tạo 1 class để tạo chuỗi connection string cho EF bằng code:
using System.Data.SqlClient;
using System.Data.EntityClient;
namespace MY_DB_ORM
{
static class MY_DB
{
public static string ConnectionString()
{
SqlConnectionStringBuilder sqlBuilder = new SqlConnectionStringBuilder();
// Set the properties for the data source.
...