Reputation: 25302
I have two edmx files at the moment: for MySQL and for SQL Lite (to make in-memory tests). And I need to map them to the same set of POCO classes. Is it okay to keep two edmx files or should I use two storage models with common mappings and conceptual model?
Update. I would like to clarify in-memory tests point. I would like to use in-memory tests only while they are run by developer locally (to make it faster). But build server will run tests on MySQL to proof it works with production-like database.
Upvotes: 3
Views: 217
Reputation: 364269
Don't use different database platforms for testing. It is absolutely wrong approach with EF. Each database can have different feature support in its EF provider so you are going to test different code.
If you really want to use two different database platforms you should use fluent API for mapping because it will make it much simpler.
When using EDMX file for mapping you always need some duplicity. Obviously your classes must remain the same and so your conceptual model must remain the same as well. That means CSDL part of both EDMX files must be the same. SSDL part must be different because it is targeted to given database platform. MSL part must be different only if tables in SSDL have different names, different columns, different schemes or relations have different names.
If you want to reduce duplicity you should not use EDMX at all but work with CSDL, MSL and SSDL files directly - you will lose designer support. This is perhaps correct but much harder to use.
The simplest approach is keeping everything same except database provider and let some prebuild script update second EDMX for SQLite from the main EDMX fro MySQL - the script, helper application or XSLT transformation for this update is completely up to you.
Upvotes: 3