After first meeting at a summer camp as teenagers, Emma (Natalie Portman) and Adam (Ashton Kutcher) run into each other a few times as young adults but never keep in touch. Emma becomes a doctor in Los Angeles, Adam a production assistant for a musical television show. Adam's father Alvin (Kevin Kline), the well-known star of a former hit television comedy series, has begun a romance with Adam's ex-girlfriend, Vanessa (Ophelia Lovibond). Adam finds out, gets drunk and calls the women in his phone seeking a hookup. The next morning, he wakes on a sofa wearing nothing but a small towel. It turns out that he texted Emma and then came to the apartment she shares with some other residents—Patrice (Greta Gerwig), Shira (Mindy Kaling), and Guy (Guy Branum). Once there, he took off all his clothes and then passed out. Emma leads Adam to her bedroom to retrieve his missing pants and they end up having sex.
The two have sex again at Adam’s house and before she leaves Adam agrees to her proposal for a casual relationship (as she puts it, using each other for sex and nothing else). Adam warns Emma about falling in love with him, but she dismisses the idea and sets ground rules to keep what they’re doing from becoming too serious. At first things go well, but Adam becomes jealous when Sam (Ben Lawson)—another resident—seeks her attention. Adam brings Emma a gift (a mix CD) and she rebuffs him, saying they should stop for a while and hook up with other people. But after being apart for two weeks Emma returns to Adam and they continue being sex friends only.
Adam's birthday comes along a few months later. He goes out for dinner with Alvin and Vanessa, who announce their plan to have a baby together. Emma berates the other couple while defending Adam. He persuades her to go out together on Valentine's Day. Things fall apart when she becomes too uncomfortable during the date. An angry Emma advises Adam that he should find someone else who won’t hurt him. Adam tells Emma that he loves her—something she's not at all receptive to hearing—they have a fight, ending their arrangement.
Six weeks later, a script Adam wrote is being filmed. He gets a regular writing job on the show with the help of Lucy (Lake Bell), the show's assistant director, who is clearly attracted to Adam. Meanwhile, Emma is depressed over not being with Adam. The situation is compounded and complicated by her younger sister Katie's (Olivia Thirlby) wedding the next day and her widowed mother (Talia Balsam) arriving for the event with a male companion (Brian Dierker) of her own. Emma feels she is being strong for her mom by not letting herself get too close to anyone so she won't become upset by seeing Emma get hurt if a relationship ends poorly. Emma's mom tells her to stop.
When Emma confesses that she can't stop thinking about Adam, Katie insists that she call him to put things right. A nervous Emma phones Adam and tells him that she misses him. He responds that they were never really together. Realizing that she needs to speak with him in person, Emma leaves Santa Barbara where the wedding is taking place and drives to Adam's house. Her plans are ruined – and she has to hide to avoid being seen—when he arrives home with Lucy. Emma assumes Adam has a new girlfriend and tearfully drives away. Vanessa calls Adam before he and Lucy can have sex—Alvin has overdosed on a cough syrup-based drink called "Purple drank". Meeting Adam outside the hospital, Vanessa says that she is ending her relationship with Alvin and leaves for a party. Adam goes in to visit Alvin who surprisingly gives him some tender advice about falling in love.
Shira tells Emma about Adam's dad being admitted to the hospital. As Adam leaves the building he calls Emma and tells her that she must be present if she is going to say that she misses him. Emma gets out of her car as the call ends and Adam is stunned to suddenly find her there. She tells Adam that she is sorry she hurt him and confesses that she really loves and cares about him and they reconcile. After eating breakfast together the next morning—something that never happened before—they arrive in Santa Barbara just before Katie's wedding is starting. As they enter a room and pause Emma asks Adam what will happen next, and with a smile on his lips he silently intertwines her hand with his—for the first time they are holding hands together as a couple.
The end credits show an epilogue in which Alvin and Lucy are in a relationship, and are in a restaurant waiting for Adam to arrive to tell him. Adam’s roommate (Jake Johnson) and Patrice are in a relationship and are shown meeting his two dads. Vanessa had told Adam that old people scare her and she is ridden with anxiety when she is trapped in an elevator full of senior citizens. Adam and Emma are seen kissing in the park. Sam and Shira are in a relationship, but he wants his freedom and isn't pleased when she reveals that she’s already been seeing other men. Katie is having a baby and Emma is the delivering doctor. Guy lures a nervous-looking Sam into a hospital room. At last, Adam and Emma are shown peacefully sleeping together.

Question: Who is Alvin dating at the end?
Answer: Lucy