public static void Delete(Employee employee)
 {
     using(var ctx = new SoftUniEntities())
         {
             ctx.Entry(employee).State = EntityState.Deleted;
             ctx.SaveChanges();
         }
 }
    //a class for inserting, finding by key, modifying and deleting an entity
    public static void Add(Employee employee)
    {
        using(var ctx = new SoftUniEntities())
            {
                var entry = ctx.Entry(employee);
                entry.State = EntityState.Added;

                ctx.Employees.Add(employee);
                ctx.SaveChanges();
            }
    }
        static void Main(string[] args)
        {
            var ctx1 = new SoftUniEntities();

            var employee1 = ctx1.Employees.Find(1);
            employee1.FirstName = "Gosho";

            var ctx2 = new SoftUniEntities();

            var employee2 = ctx2.Employees.Find(1);
            employee2.FirstName = "Vanka";

            ctx1.SaveChanges();
            ctx2.SaveChanges();
        }
    public static void Modify(Employee employee, string newName)
    {
        using(var ctx = new SoftUniEntities())
            {
                //ctx.Employees.Attach(employee);

                string[] name = Regex.Split(newName.Trim(), @"\s+");
                string firstName = Regex.Split(newName.Trim(), @"\s+")[0];
                employee.FirstName = firstName;

                if (name.Length == 2)
                {
                    string lastName = Regex.Split(newName.Trim(), @"\s+")[0];
                    employee.LastName = lastName;
                }

                var entry = ctx.Entry(employee);
                entry.State = EntityState.Modified;

                ctx.SaveChanges();
            }
    }