I have a code block that is implicitly adding variables to an array, i.e.
context.People.Add(
new Person { Name = "Joe", Age = 45 },
new Person { Name = "Alicia", Age = 33 } );
What I need is for the variables to be accessible outside of the code block, i.e.
var personJoe = new Person { Name = "Joe", Age = 45 };
var personAlicia = new Person { Name = "Alicia", Age = 33 };
context.People.Add(personJoe, personAlicia);
This way I can access the person variables when I need to make an assignment to another entity that has a relationship with person.
My question is, what is the easiest way to perform this refactoring? I understand I can copy/paste, but the block I have is approximately 200 lines long, and I have found myself needing this type of re-factoring often. If at all possible, I would like to avoid paid solutions (ReSharper), but if this is the only way to get this process automated, I will seriously consider it.