LINQ to SQL or Entity Framework again for new MVC 3 project

first of all, my background: a rather large database (~ 100 tables with ~ 10-20 columns each) on MS SQL Server, and it will always be SQL Server and the database.

I have some experience with WebForms and LINQ to SQL, but Iโ€™m tired of creating forms for editing all the tables mentioned, so the mvc 3 razor is with it. Forests just mesmerized me, and I dream about it, generating all this forms for me

but it comes out (or maybe I'm not getting something) that scaffolding only works for EF DbContext. for L2S, it says "unsupported DbContext". I tried MvcScaffolding with LinqToSqlScaffolding (typed "Set-DefaultScaffolder Repository LinqToSqlScaffolding.Repository" in the PM console) but still did not sing L2S โ€‹โ€‹mapping.

So, the first question: "Is there a way (stable way) to get forests for Linq to SQL classes"

Now Iโ€™ve researched some and found all these topics about L2S vs EF, saying the same thing: โ€œL2S came first, so itโ€™s more stable, and EF is still young, but itโ€™s a long shot, itโ€™s flexible, displayed, etc.โ€

The first thing I donโ€™t understand is how can I map this flexible model to my enterprise database? I used the constructor to create a class for EF DbContext, as I already did for L2S, and for L2S it consists of ~ 42000 lines. Now I need to find some properties of the object and set some attributes for them, such as "Required", "Show" and "Range", but the designer will overwrite them. I know how to implement a partial class or partial method, but I do not know what to make any additions to the properties in the external file, because the developer could not overwrite them. I think this should be the second question.

and if I have to compare my enterprise database with EF hands so that it is flexible ... o_O that ~ 42,000 lines of the auto-generated class scares me with bees! Is it really necessary?

+3
linq-to-sql asp.net-mvc-3 entity-framework scaffolding
Jul 14 '11 at 12:45
source share
2 answers
  • Entity Framework has progressed a bit recently. I consider it "stable." The new integration with MVC3 is outstanding.
  • Regarding adding custom DataAnnotation attributes for validation, this article describes an approach using EF. (Scroll down.) Since you cannot modify the created properties, custom metadata is used to apply them.
  • You really want it to generate as much as possible for you so as not to go crazy. EF has a construction surface very similar to L2S, and you can get the most difficult or complex task.

In addition, MVC3 will generate strongly typed views for you based on any object model. The main difference is that with EF it will connect ALL to you, while with custom POCO or L2S you must do all the plumbing yourself. (From this point of view, this works exactly the same as previous versions of MVC.)

+6
Jul 14 '11 at 13:16
source share

With my limited experience, I feel that calling EF directly from the controller does not look very good. I think the database should be accessed through a separate layer. I prefer the controller to call the WCF service, which can talk to the database using ADo.NET/LINQtoSQL/EF/NHibernate.etc.

Suggestions and disagreements are welcome. But please do not reduce - this is my thought. :-)

References:

  • WCF service with asp.net mvc application
0
Feb 17 '12 at 18:23
source share



All Articles