private static void NotWorkingUpdateOnNullOwnedType(DbContextOptions <CandidateDbContext> builderOptions)
        {
            long?candidateId = null;

            using (var dbContext = new CandidateDbContext(builderOptions))
            {
                var candidate = new Candidate()
                {
                    FirstName = "FirstName"
                };

                dbContext.Add(candidate);
                dbContext.SaveChanges();
                candidateId = candidate.Id;
            }

            using (var dbContext = new CandidateDbContext(builderOptions))
            {
                var candidate = dbContext.Candidates.SingleOrDefault(c => c.Id == candidateId);

                if (candidate != null)
                {
                    candidate.Address = new Address()
                    {
                        Street     = "Street2",
                        PostalCode = "Postal2"
                    };
                    dbContext.SaveChanges();
                }
            }
        }
Esempio n. 2
0
 public async Task Create(Candidate candidate)
 {
     _context.Add(candidate);
     await _context.SaveChangesAsync();
 }