Generating Object-Layer Code is the easiest way to generate code for database instead of writing the for yourself. refer to Generating Object-Layer Code
Code can be generated for Object-Layer as follows:-
1. Create an Entity Data Model design
2. Right click on EDM design and select "Update Model from Database..."
3. Select the database and select the required table
4. Select finish to get the code generated
The code is now generated and is ready to be used.
Now consider you have modified the database tables and would like to update Object-Layer code. Just need to run the steps from 2 to 4.
But you might have observed that the code does not get updated, the reason being the code is generated only first time it is created.
This is a feature which is provided so that customised changes to the code does not get lost when re-generating the code.
So to overcome this create another class that extends this class and add all your custom code to the derived class.
Every time you update the database
- Remove the contents of the file TestDatabase.Designer.cs.
- Re-run the steps from 2 to 4, this will recreated the code that reflects the database changes
To have no errors
Would be life without meaning
No struggle, no joy
~Brian M. Porter, 1998
0 comments:
Post a Comment