[SalesForce] Illegal assignment from sObject to Id

I'm trying to insert two master-detail lists at the same time. I'm looking through Bob Buzzard's blog post: http://bobbuzzard.blogspot.com/2012/03/create-parent-and-child-records-in-one.html Where he uses this snipit to create an Account and Contact.

Account acc=new Account(Name='Blog Acc 8', Master_Id__c='Blog Acc 8');
Contact cont=new Contact(FirstName='Bob', LastName='Buzzard', Account=new Account(Master_Id__c='Blog Acc 8'));

I think I'm doing the same thing but I get this error when I try to instantiate parent:

Illegal assignment from Revenue_Pipeline__c to Id

I have one method where I'm creating the parent record:

public static void actions(List<Project_Submission__c> projSubList)
{
    List<Revenue_Pipeline__c> revPipeToUpsert = new List<Revenue_Pipeline__c>();
    List<Revenue_Pipeline_Schedule__c> revPipeSchedule = new List<Revenue_Pipeline_Schedule__c>();

    for(Project_Submission__c ps : projSubList)
    {
        Date launch = ps.Target_Launch_Date__c.toStartOfMonth();
        String fy = String.valueOf(launch.year());
        Date endDate = getfiscalEndDate(fy);
        Date startDate = getfiscalStartDate(fy);

        if(ps.Year_1_Commercial_Budget__c != null)
        {
            String ext = ps.Id + '-' + 'CommercialBudget';

            Revenue_Pipeline__c revPipe = new Revenue_Pipeline__c();
            revPipe.External_Id__c = ext;
            revPipe.NPD_Forecast_Category__c = 'Commercial Budget';

            revPipeSchedule.addAll(createschedule(ps.Id, launch, endDate, ps.Year_1_Commercial_Budget__c, ps.CurrencyIsoCode, ext));
        }

Then another method where I am creating the children

public static List<Revenue_Pipeline_Schedule__c> createSchedule(Id projSubId, Date startDate, Date endDate, Decimal price, String cur, String ext)
{
    List<Revenue_Pipeline_Schedule__c> revenueScheduleList = new List<Revenue_Pipeline_Schedule__c>();

        Integer numOfMonths = startDate.monthsBetween(endDate) + 1;
        Decimal amount = price/numOfMonths;

        for(Integer i=0; i < numOfMonths; i++) 
        {
            Revenue_Pipeline_Schedule__c revSchedule = new Revenue_Pipeline_Schedule__c(
                Amount__c = amount,
                Date__c = startDate.addMonths(i),
                //Name = projSubId + ' - ' + Date__c.year() + '-' + Date__c.month(),
                CurrencyIsoCode = cur,
                Revenue_Pipeline__c = new Revenue_Pipeline__c(External_Id__c = ext)); <----- Error Here
            revenueScheduleList.add(revSchedule);           
        }
    return revenueScheduleList;
}

What am I doing wrong?

Best Answer

You should be using the relationship name instead of the object name.

Replace below code which is giving the error

Revenue_Pipeline__c = new Revenue_Pipeline__c(External_Id__c = ext));

With

Revenue_Pipeline__r = new Revenue_Pipeline__c(External_Id__c = ext));

Note the __r in the above statement.