Actually i have about 12 tables which i need to join and get the data. Now my question is i am using Entity framework 4.1 should i write one view in db and pull in entity framework (.edmx file) or should i pull all tables in .edmx and write my Linq query
there, I am thinking its batter to write view and pull in .edmx file.
Creating as a view will give you absolute control over the query that gets called. Plus you can then use SQL query tools to optimise with additional indexes etc.
If it helps, mark as answer - your approval helps with my recovery ;)
Since i am using EF why you are suggesting ado.net datatable, Can you explain??
What I mean this is because I'm considering——if you have too many tables to be generated into an edmx file,I'm afraid the file will be too large for you to view……So I say that you can use the advantages of the traditional ADO.NET to deal with that。
Ok, But is there any way i remove .demx project from my solution and generate model from there and add in my Model folder so i can use entity framework and there will no dependency for .edmx file and no warries about how heavy my edmx file is?
Ok, But is there any way i remove .demx project from my solution and generate model from there and add in my Model folder so i can use entity framework and there will no dependency for .edmx file and no warries about how heavy my edmx file is?
If you are using EF(DataBase-first or ModelFirst),you cannot leave edmx;however if you are using Code-First,you can!:-)
Data-Base first means working with existing database?
Yes,you should create an edmx file first and then import the Database directly into the file,it will convert automatically from datatables to model entities……,but it doesn't what you want……You don't need edmx file,do you?So Code-First is your choice。
braveboy76
Member
103 Points
96 Posts
Best practice for entity framework
May 24, 2012 08:55 PM|LINK
Actually i have about 12 tables which i need to join and get the data. Now my question is i am using Entity framework 4.1 should i write one view in db and pull in entity framework (.edmx file) or should i pull all tables in .edmx and write my Linq query there, I am thinking its batter to write view and pull in .edmx file.
Tell me what is the best practice.
Thanks
kashifilyaz
Participant
1144 Points
198 Posts
Re: Best practice for entity framework
May 24, 2012 08:57 PM|LINK
You should write view in database for this
kidshaw
Participant
1158 Points
252 Posts
Re: Best practice for entity framework
May 24, 2012 09:00 PM|LINK
Decker Dong ...
All-Star
118619 Points
18779 Posts
Re: Best practice for entity framework
May 26, 2012 02:23 AM|LINK
Hello:)
1)Use as many as Views for yourself to simplify the sql statement。
2)Use Stored Procdures as much as possible。
3)If you want to get a high speed,maybe you don't need to put all of the tables to convert them into EF models……
4)Just use ADO.NET DataTables instead of EF to save time。Maybe this will be something faster。
braveboy76
Member
103 Points
96 Posts
Re: Best practice for entity framework
May 29, 2012 02:02 PM|LINK
Hi Decker Dong...
I did not understand point 4, Since i am using EF why you are suggesting ado.net datatable, Can you explain??
Thanks
Decker Dong ...
All-Star
118619 Points
18779 Posts
Re: Best practice for entity framework
May 30, 2012 01:18 AM|LINK
What I mean this is because I'm considering——if you have too many tables to be generated into an edmx file,I'm afraid the file will be too large for you to view……So I say that you can use the advantages of the traditional ADO.NET to deal with that。
Reguards!
braveboy76
Member
103 Points
96 Posts
Re: Best practice for entity framework
May 30, 2012 07:09 PM|LINK
Ok, But is there any way i remove .demx project from my solution and generate model from there and add in my Model folder so i can use entity framework and there will no dependency for .edmx file and no warries about how heavy my edmx file is?
Decker Dong ...
All-Star
118619 Points
18779 Posts
Re: Best practice for entity framework
May 31, 2012 12:52 AM|LINK
If you are using EF(DataBase-first or ModelFirst),you cannot leave edmx;however if you are using Code-First,you can!:-)
For more about Code-First,you can see this:
http://weblogs.asp.net/scottgu/archive/2010/07/16/code-first-development-with-entity-framework-4.aspx
And you can download the latest Code-First dll file from NuGet.
Reguards!
braveboy76
Member
103 Points
96 Posts
Re: Best practice for entity framework
May 31, 2012 03:04 PM|LINK
Data-Base first means working with existing database? If yes then i am using existing database and pull tables in my .edmx. Please suggest
Decker Dong ...
All-Star
118619 Points
18779 Posts
Re: Best practice for entity framework
Jun 01, 2012 01:08 AM|LINK
Yes,you should create an edmx file first and then import the Database directly into the file,it will convert automatically from datatables to model entities……,but it doesn't what you want……You don't need edmx file,do you?So Code-First is your choice。
Reguards!