0

UPDATE: I understand that I can go from 2 to 3 by creating a DB and then creating entity model from the framework. I am looking for a way to create the entity model without creating a DB.

1) I am trying to use entity framework 5.

2) I have my poco classes.

3) I want to generate an entity model.

How do I go from 2 to 3?

I can create an entity model, but my only options are to create from an existing db or an empty model. I don't have an existing db, so I select an empty model.

I then get a great looking tool to create entities. However, it is empty and I want to create entities that will match up with my poco classes.

How do I take my existing poco classes and transform them into the entity model?

yamspog
  • 18,173
  • 17
  • 63
  • 95

2 Answers2

0

You can use CodeFirst and then use PowerTools to "visualize your model" which is using EdmxWriter undercover. EdmxWriter is used to dump a CodeFirst model to an .edmx file which then can be opened in Visual Studio (double click on the file). Note that the edmx file will not be used at runtime (that's why the option is called "visualize"). If you already have an existing database you can try using the EF designer to reverse engineer the database. In this scenario (if you are using VS2012 or VS2013) the designer will create a model in form of the edmx file and will generate POCO entities that will be in synch with the file. If you already have POCO entities and an existing database you need to make sure that they are in sync and then you could try the "CodeFirst" to an existing database (see the video posted by GETah in the comments) and also this post. Note that if the POCO entities you have and the database are not in sync you will likely get some wierd errors.

Pawel
  • 31,342
  • 4
  • 73
  • 104
0

If you have your POCO then I think EF Code First Development can be your next step.

Steps:

  1. Create Plain Old CLR Objects (POCO) [Business Object, Model or ViewModel]

  2. Get EntityFramework 5.0 (NUGET)

  3. Create a Context class that inherits from DbContext

  4. Create DbSet that represents entity set for CRUD operations for your type T.

Then you are good to go.

In addition, Check the following blog post:

http://weblogs.asp.net/scottgu/archive/2010/07/16/code-first-development-with-entity-framework-4.aspx

KrishnaDhungana
  • 2,604
  • 4
  • 25
  • 37