I'm in the process of converting an extensive EDMX model into POCO classes. I need to go from a Database First approach (EDMX with ObjectContext) to a pure Model First approach (DbContext with no EDMX file). I need to use the latest Entity Framework stable version: 6.1.1.
I've tested some approaches:
EF 6.x DbContext Generator
code generation item by right-clicking the blank space in EDMX designer. This works fine, but it doesn't add any mappings. With this approach I have to still use the EDMX file. It's not full Code First.My requirements:
What do you think would be a good option for me to go?
The project is now open for editing. Right click on Data Model and in the resulting submenu, select Import Data Model from File to import a metadata/edmx type file. The Wizard Step 1 of 3: File Import appears. Choose Browse to select and import a xml or an edmx file and click Next.
Well i don't think there is an easy one click solution to this.
Underneath you edmx files. You have two more files available besides the xx.Designer.cs
and xx.edmx.diagram
.. called xx.Context.tt
and xx.tt
where xx
is the name of your edmx model.
These are t4 templates which genrate your dbcontext and poco objects. All your poco objects would be created underneath your xx.tt
files and dbcontext underneath your xx.Context.tt
files.
You now have to moves these into separate files. This is much easier if you are using EF6. and the file generated are already using DbContext and not ObjectContext.
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With