I am developing an ASP .Net MVC 3 application using C# and SQL Server 2005. I want to load data from my database in a ListBox, i did many searchs but i don't find anything where Entity Framework is used. Infact, i tried many solution but always VS didn't accept the syntaxe.
This my model Class :
 
using System;
using System.Collections.Generic;
using System.ComponentModel.DataAnnotations;
using System.Globalization;
using System.Web.Mvc;
using System.Web.Security;
using System.Data.SqlClient;
using System.Data.Entity;
namespace MvcApplication2.Models
{
    public class Profile_Ga
    {
        [Key]
        public string ID_Gamme { get; set; }
        public string In_Ga { get; set; }
        public string Out_Ga { get; set; }
        public string Next_Gamme { get; set; }
        public string Etat { get; set; }
 }
}      
I want to display ID_Gamme in a listBox ? In the view i did like this by it is not accepected :
<%: Html.ListBoxFor(model => model.ID_Gamme) %>
and this is my controller :
 
using System;
using System.Collections.Generic;
using System.Data;
using System.Data.Entity;
using System.Linq;
using System.Web;
using System.Web.Mvc;
using MvcApplication2.Models;
namespace MvcApplication2.Controllers
{ 
    public class ProfileGaController : Controller
    {
        private GammeContext db = new GammeContext();
        //
        // GET: /ProfileGa/
        public ViewResult Index()
        {
            return View(db.Profil_Gas.ToList());
        }
        //
        // GET: /ProfileGa/Details/5
        public ViewResult Details(string id)
        {
            Profile_Ga profile_ga = db.Profil_Gas.Find(id);
            return View(profile_ga);
        }
        //
        // GET: /ProfileGa/Create
        public ActionResult Create()
        {
            
            return View();
        } 
        //
        // POST: /ProfileGa/Create
        [HttpPost]
        public ActionResult Create(Profile_Ga profile_ga)
        {
            if (ModelState.IsValid)
            {
                db.Profil_Gas.Add(profile_ga);
                db.SaveChanges();
                return RedirectToAction("Index");  
            }
            return View(profile_ga);
        }
        
        //
        // GET: /ProfileGa/Edit/5
 
        public ActionResult Edit(string id)
        {
            Profile_Ga profile_ga = db.Profil_Gas.Find(id);
            return View(profile_ga);
        }
        //
        // POST: /ProfileGa/Edit/5
        [HttpPost]
        public ActionResult Edit(Profile_Ga profile_ga)
        {
            if (ModelState.IsValid)
            {
                db.Entry(profile_ga).State = EntityState.Modified;
                db.SaveChanges();
                return RedirectToAction("Index");
            }
            return View(profile_ga);
        }
        //
        // GET: /ProfileGa/Delete/5
 
        public ActionResult Delete(string id)
        {
            Profile_Ga profile_ga = db.Profil_Gas.Find(id);
            return View(profile_ga);
        }
        //
        // POST: /ProfileGa/Delete/5
        [HttpPost, ActionName("Delete")]
        public ActionResult DeleteConfirmed(string id)
        {            
            Profile_Ga profile_ga = db.Profil_Gas.Find(id);
            db.Profil_Gas.Remove(profile_ga);
            db.SaveChanges();
            return RedirectToAction("Index");
        }
        protected override void Dispose(bool disposing)
        {
            db.Dispose();
            base.Dispose(disposing);
        }
    }
}
There is any solution ?