Plateforme Level Extreme
Abonnement
Profil corporatif
Produits & Services
Support
Légal
English
Database First Import
Message
 
À
16/01/2013 15:45:02
Joel Leach
Memorial Business Systems, Inc.
Tennessie, États-Unis
Information générale
Forum:
ASP.NET
Catégorie:
MVC
Versions des environnements
Environment:
C# 5.0
Database:
MS SQL Server
Divers
Thread ID:
01562068
Message ID:
01564073
Vues:
55
>>As the name suggests: Code First is meant as a coding tool and not a Wizard interface. The other Entitity Framework modes - Database First and Model First are better aimed to deal with complete database imports than Code First which is meant as a coded approach to generating a database from the model.
>>
>
>Regardless of where you start, you end up with all three (database, model, code) right? Or is that only because I'm using the scaffolding?

No that's only because of the scaffolding. Imports should only generate the model - whether it's a CodeFirst classes model or a EDMX model (for classic EF with ObjectContext). The EDMX approach allows for a visual designer and some two way data updates. Code First requires coded models that update the database (either automatically, manually or via migrations). The Scaffolding is something separate from EF.

>By the way, do you like to use EF for MVC projects, or do you prefer something else? Also, where do you put your business logic? I'm talking code beyond simple validations. MVC Scaffolding implements a "repository" layer, but I haven't looked into what that really means.

Yes I've started using EF CodeFirst in recent projects and it works fairly well. All of the projects have been small to medium sized and I haven't really hit any limitations. Hardest part is making sure you produce valid models that can be mapped properly to the database (ie. no FK validation errors and circular references etc.).

As to business logic: I use a business object layer that sits ontop of EF - it knows about EF and provides basic CRUD operations and hooks to override common behavior. This is where all my business logic goes. The app then consumes the business object. This is similar to a repository object but with a little more internal logic and knowledge of EF baked in. It's part of the West Wind Web Toolkit if you want to check it out, but there are not a ton of examples at the moment.

You can find the code here:
http://www.west-wind.com:8080/svn/WestwindWebToolkit/trunk/Westwind.BusinessFramework/EfCodeFirst/

+++ Rick ---
+++ Rick ---

West Wind Technologies
Maui, Hawaii

west-wind.com/
West Wind Message Board
Rick's Web Log
Markdown Monster
---
Making waves on the Web

Where do you want to surf today?
Précédent
Suivant
Répondre
Fil
Voir

Click here to load this message in the networking platform