0

I'm working with a database schema that our company has used for years, and am not in a position to change the fundamental structure of it. The need for an API to access this data came up, so we decided to go with WCF Data Services and the Entity Framework. In order to have a data model that made more sense than our table structure, we have our EF models attached to SQL Views instead of tables. This has worked really well for our purposes.

Now I'm in a situation where I'm considering creating a second (updated) version of our API, while needing the existing API to continue to work for old applications, and having the two APIs running side-by-side, accessed via different URL endpoints.

I've created a new WCF Data Service endpoint for the new version, new SQL views as necessary (the names of which have "_v2" appended to them), and a new DB Context that maps the models to the new views. This also works well.

The hiccup is that I'd like to also have separate versions of the EF model classes, as I'd like implement slight differences into them. But I run into the naming conflict, where the EF framework gives the error "mapping of CLR type to EDM type is ambiguous."

The only way to have a second set of EF models with the same names is by having the models be loaded from a separate assembly. Is that my only option here? Is there some other approach I should consider?

I've also considered using the same EF model classes for both versions, and using the Ignore method when configuring the models, but this also doesn't feel ideal.

Any suggestions on alternative approaches appreciated!

1 Answer 1

1

Put the new models in a different namespace.

Namespace ModelsV2 { public class CarsV2 { ... } } 
Sign up to request clarification or add additional context in comments.

3 Comments

They were in a different namespace when I got the error. I mean, they had to be. I couldn't have the two classes with the same name in the same namespace, right?
Actually, I see now that you appended "V2" to the class name. That is an option... but an ugly one that I'd like to avoid.
@Moskie How do you plan on specifying which version of the object you want without having each version in a different assembly/namespace or using different class names? Plus, what happens when you need yet another version later on?

Start asking to get answers

Find the answer to your question by asking.

Ask question

Explore related questions

See similar questions with these tags.