Example #1
0
        static void Main(string[] args)
        {
            databasefirstEntities dbnew = new databasefirstEntities();
            Product producttb           = new Product()
            {
                id    = 4,
                title = "scale",
                price = 12
            };
            Detail detailtb = new Detail()
            {
                id       = 4,
                vendor   = "doms",
                quantity = 40
            };

            dbnew.Details.Add(detailtb);
            dbnew.Products.Add(producttb);
            dbnew.SaveChanges();
            var x = dbnew.Details.Include("Product");

            x.ToList().ForEach(
                i => { Console.WriteLine("name : " + i.vendor); });
            Console.ReadKey(true);
        }
 static void Main(string[] args)
 {
     try
     {
         var context  = new databasefirstEntities();
         var datapost = new datapost();
         {
             datapost.body          = "body";
             datapost.title         = "title";
             datapost.postid        = 1;
             datapost.datapublished = DateTime.Now;
         };
         context.dataposts.Add(datapost);
         context.SaveChanges();
     }
     catch (Exception e)
     {
         Console.WriteLine(e.Message);
     }
 }