[SalesForce] Compile Error: Illegal assignment from Id to User

Account acc = new Account();
acc.name = 'test';
insert acc;

Profile p = [SELECT Id FROM Profile WHERE Name = 'System Administrator'];

            User u = new User(
              Alias = 'testu',
              Email = 'test@ensors.com',
              EmailEncodingKey = 'UTF-8',
              LastName = 'Kulak',
              LanguageLocaleKey = 'en_US',
              LocaleSidKey = 'en_US',
              TimeZoneSidKey='America/Los_Angeles',
              ProfileId = p.Id,
              UserName='test'
            );

            INSERT u;


            Opportunity opp = new Opportunity();
            opp.Account = acc;
            opp.name = 'test';
            opp.StageName = 'Stage 1 - Qualified';
            opp.CloseDate = Date.today();
            opp.Owner = u.id;
            insert opp;

Best Answer

Here

opp.Owner = u.id;

this should be

opp.OwnerId = u.id;