Click here to Skip to main content

princektd asked:

Open original thread
I have added ADO .net Entity Framework to my project and so I see the EDMX file. When I added it, there was this pop-up (Entity Designer???) asking me to choose a datasource, and I had read that if pointed to an existing DB, the necessary Object classes/entities will be auto generated in my project. But, I closed the dialogue thinking that I will set the datasource later. So how do I set the datasource and get it to autogenerate the entities now, after closing the dialogue?
 
Is there a way to get ADO .net entity framework to autogenerate the entities using a pre/post build event, or maybe from code behind?
What if I embed a blank edmx into a class library and compile the library, then refer the library in my main (parent) project, can I get it to autogenerate the entities corrosponding to the parent project's database through code by writing something like:
myLibrary.myEntityModel.functionToAutoGenerateEntities();
somewhere in the parent project start/entry point, then run the parent project so that this gets executed and creates the necessary files, after which I comment out the above line so that successive builds and runs do not generate/modify the entities again?
 
OP's additional information moved from non-solution below
dear prataph,
Mine is a DB first approach.
Say, i have a DB with a table named person.
It has 2 columns:
VARCHAR FirstName & INT Age

Now, in our program, we will create an object class
Person.cs
 Class Person
 {
   string _firstName;
   int _age;
  
   public string FirstName
   {
     get{return _firstName;}
     set{_firstName = value}
   }
  
   public string Age
   {
     get{return _age;}
     set{_age = value}
   }
 }

or something similar. When the DB is complex and has many tables and columns, it gets difficult to create these classes.

I read somewhere that ADO .Net Entity Framework can automatically generate these object/class .cs files for you. That kind of makes a developers work easier and his/her time more productive...

How can this 'autogenerate object class' functionality of ADO .net be called from code behind?
Or can it be called only from the visual studio UI by right-click or when adding a new .edmx file?
Tags: C#, ADO.NET, ORM, VisualStudio2012

Preview



When answering a question please:
  1. Read the question carefully.
  2. Understand that English isn't everyone's first language so be lenient of bad spelling and grammar.
  3. If a question is poorly phrased then either ask for clarification, ignore it, or edit the question and fix the problem. Insults are not welcome.
Let's work to help developers, not make them feel stupid.
Please note that all posts will be submitted under the The Code Project Open License (CPOL).



Advertise | Privacy | Mobile
Web04 | 2.8.1411019.1 | Last Updated 26 Mar 2009
Copyright © CodeProject, 1999-2014
All Rights Reserved. Terms of Service
Layout: fixed | fluid

CodeProject, 503-250 Ferrand Drive Toronto Ontario, M3C 3G8 Canada +1 416-849-8900 x 100