I am porting an application’s persistent storage mechanics from SQL Compact to Oracle.
Current Implementation
The application implements Entity Framework 5 (EF), but it is pretty tightly coupled: (a) there is no service layer between EF and the Controllers, and (b) there is no IRepository-style abstraction between EF and SQL Compact.
The C# models are simple POCOs but are rich with data annotations, and is used “code-first” style to generate DB schema.
Problem (Oracle)
I must use Oracle’s standard ODP.Net provider. The provider supports EF, but does not support “code-first” methodology, only “model first”.
Intended Solution
I am trying to find a way to preserve the EF implementation tightly coupled to the controllers, and the richness of the model class annotations, while using them to build the “model-first” style EDMX file that Oracle can swallow. Essentially, I am looking for a way to mimic “code-first”.
I was hoping it would be as simple as dragging my C# objects onto the EDMX file but it seems like there’s much more going on.
Question
How can I build an .EDMX file using C# models that already exist? If it is not possible, what is the next best solution for accomplishing this goal?
If you have DbContext you can use ‘EdmxWriter.WriteEdmx()’ to write your model as the edmx file that you should be able to open with the designer.