Reputation:
I have been using Linq-to-SQL for a while to get access to my database. But I have recently been told this way of doing was not the best one since it allows to mix the data access & business logic layers.
I heard that Entity Framework T4 POCO was a solution but I cannot find complete information about it. Does anyone have more details to share with me ?
Thanks in advance
Upvotes: 4
Views: 4055
Reputation: 9002
See that: Entity Framework - Generating Classes
There is a tutorial how to generate POCO Classes by existing database.
Upvotes: 0
Reputation: 3575
What a POCO (Plain Old CLR Object) does it that it allows you to create your own representation class of your database. Entity Framework then converts your database (through a configuration (hint use an edmx file)) to the by you created POCO classes.
Example:
Table User:
id | fName | lName | otherField
You can represent this in your C# with a POCO to a user object with the following properties:
int id, string fName, string lName, var otherField.
Then you can, in the getters and setters of these properties, insert your business logic.
NOTE: I'd recommend using just the Entity Framework icm with an edmx file. And put your business logic somewhere else. When creating a web service I always like the following order of classes :
Upvotes: 1
Reputation: 1
I find this site gives a great example on how to use EF4 with POCO classes.
This describes the 'code first' approach for Entity Framework 4
Upvotes: 0