1

We're have a couple of projects that integrate a business system to different external services. "We" are only writing the middleware and have no control of either system. When a breaking change occurs in a new version we'll have to cope somehow.

Environment we're using is VS2013, C# and EF 5.0-6.NN

The resources we rely on are: A number of Entity Framework models (model first for now, but is subject to change ). 3 dlls that needs to referenced.

The resources have been very backward compatible until friday when we got a breaking change on the datatype of one field in one of the dlls. (Went from int to string).

How can one approach this: Is it possible to load the same EF that targets different versions of the database? I understand that one would be forced to load them by different dll:s and so on, but then, how should one approach the say linq queries and so on?

Is it viable at hotspots do a check for say the type and recreate the whole LINQ expression?

if(typeof(Items.Prop) == typeof(int)){
  var things = from x in framework.Items where x.Prop = 2 select x;
} else if(typeof(Items) == typeof(string)){
  var things = from x in framework.Items where x.Prop = "2" select x;
}

Though, this should fail depending on the linq expression evaluation, since we're comparing it to the wrong datatype.

Or should one create a specific executable for each version of the resource using

#ifdef __VER10
  var things = from x in framework.Items where x.Prop = 2 select x;
#endif
#ifdef __VER9
  var things = from x in framework.Items where x.Prop = "2" select x;
#endif

But then, is it possible to do this automated tools that is provided by Visual Studio. And deployment of the correct executable becomes a problem in itself.

This question might be too loose for stack overflow, and I assume this is a common problem, but I'm not certain how to google for an answer.

lungic
  • 344
  • 1
  • 13

1 Answers1

1

You should always provide specific executables for different versions of an API/resource.
You cannot really automate it using Visual Studio but you can create different build configurations using the Configuration Manager.
See here on how to adjust the references: Visual Studio: Different DLLs for configurations
You can then specify a build variable like __VER9 or __VER10 by going to Project->Properties->Build->Conditional configuration symbols.
These symbols are briefly explained here, but it's basically what you're looking for: http://msdn.microsoft.com/en-us/library/aa691095(v=vs.71).aspx

Community
  • 1
  • 1
Matt Ko
  • 969
  • 7
  • 14
  • Even if the comment above (Nader) could help solve my problems, it would make sense to build a new resource each time, especially validate datatypes hard through the compiler. Thanks, now I have a starting point to go from. – lungic Oct 26 '14 at 16:21