c# - Switching form EF4 to EF5 switching new to create -


previously when using ef4 objects being added database followed (possibly incorrectly) pattern

poll opoll = new poll(); opoll.name = "my special poll question"; context.addtopolls(opoll); context.savechanges(); 

however when making switch ef5 need make use of create object instead.

poll opoll = context.poll.create(); opoll.name = "my special poll question"; context.addtopoll(opoll); context.savechanges(); 

since have 3,000 pages of code, rather not find new keywords nor go through hand hand. there nice elegant way (by tool or otherwise) update pattern new pattern ef5?

if know names of entities, global regex replace:

say had poll, vote , person types, replace:

(poll|vote|person) (.+) = new .+\(\); 

with

$1 $2 = context\.$1\.create\(\); 

that'd turn poll opoll = new poll(); poll opoll = context.poll.create();

to add entity types want replace, edit first part of regex.


Comments

Popular posts from this blog

java - Jmockit String final length method mocking Issue -

asp.net - Razor Page Hosted on IIS 6 Fails Every Morning -

c++ - wxwidget compiling on windows command prompt -