Watch this example on YouTube
All details - how to create this project are in the YouTube movie above.
You will need to create Customer class in Model folder with the following code
using System.Web;
using System.Data.Entity;
namespace MVCCrud.Models
{
public class Customer
{
public int ID { get; set; }
public string Name { get; set; }
}
public class CompanyDBContext : DbContext
{
public DbSet<Customer> Customers { get; set; }
}
}
Also you will have to add the following code to web.config file
<add name="CompanyDBContext"
connectionString="Data Source=(LocalDB)\v11.0;
AttachDbFilename=|DataDirectory|\CompanyDB.mdf;
Integrated Security= True" providerName="System.Data.SqlClient" />
</connectionStrings>
No comments:
Post a Comment