Start New Discussion within our Software Development Community

Hi I am the new in C# and I do some semestral project, I have done generating the entity data model, and I want to connect to the database from class by dbcontext using the ConnectionString. I have problem to bind a connection to these database. Can someone help me?

There are my classes:
1.) this classes throw me warning that is obsolete

public static class ConnectionSettings
        public static String ConnectionString = ConfigurationSettings.AppSettings[@"data source=(localdb)\v11.0;initial catalog=SusibarDatabase;integrated security=True;MultipleActiveResultSets=True;App=EntityFramework""];


2.)this is the the second: EntityContainer is the name in configuration of xml

ublic class ItemDbContext : DbContext
         public ItemDbContext()
             : base("EntityContainer")
         { }

         public DbSet<Item> Items { get; set; }

3.)this is the class to adding data into database

public class RequestModel

        private EntityDbContext.ItemDbContext dbContext = new EntityDbContext.ItemDbContext();

        public int GetUnifishedRequestsCount() { return 5; }

        public void TestInsert() 
            Item i = new Item();
            i.Id = 1;
            i.Name = "Test";
            i.Created = DateTime.Now;
            i.Deleted = false;



4.)the main

class Program
        static void Main(string[] args)
            model.RequestModel model = new model.RequestModel();




OK i will use SqlConnection it was my first choice but i use that.

This article has been dead for over six months. Start a new discussion instead.