Click here to Skip to main content
12,821,041 members (33,332 online)
Rate this:
Please Sign up or sign in to vote.
See more: MVC4
public class SdSolDBController : Controller
        SdSolDB _db = new SdSolDB();

        public ActionResult Index()
            var model = _db.Categories;
            return View(model);

This is my Controller which is conntecting with my database.

public class Category
        public int CategoryID { get; set; }
        public string CategoryName { get; set; }
        public int EvaluationType { get; set; }
        public string CreatedBy { get; set; }
        public DateTime CreatedDate { get; set; }

These Are my Enities...

public class SdSolDB:DbContext
        public DbSet<Category> Categories { get; set; }

This is my DBcontaxt file...

My database is already exist.
but when i use this code.and give some other test database name it generate new table with name Category in that database.

But i dont need that
i want to use my already created database.

How can i do that???

please help me
and if u have a good vedio tutorial about it.then plz give me a download link also

thanks in advance...
Posted 25-Feb-13 5:53am

This content, along with any associated source code and files, is licensed under The Code Project Open License (CPOL)

    Print Answers RSS
Top Experts
Last 24hrsThis month

Advertise | Privacy | Mobile
Web02 | 2.8.170308.1 | Last Updated 25 Feb 2013
Copyright © CodeProject, 1999-2017
All Rights Reserved. Terms of Service
Layout: fixed | fluid

CodeProject, 503-250 Ferrand Drive Toronto Ontario, M3C 3G8 Canada +1 416-849-8900 x 100