Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

How far Entity framework code first fits in Enterprise

I need to decide on the usage of Entity framework for a large enterprise application. I need to decide either on EF data first / Code first.

My main idea is not to mix Data Access with Database. I don't want any tool to generate/update database. I can design database schema first and can use EF Data first model. The problem with this approach is

Less control over the code generated by the EF and Huge configuration

I can use code first approach to solve above problems. But the problem with code fist is tight integration with database and EF. whenever I change my Model I need to create Migrations to update the changes to the DB. I am little worried with the changes "Migrations" will make to my DB. moreover If we have to apply these changes to Production DB its not at all possible as we development team won't have any access to production servers.

I am just thinking weather it is a good choice to choose EF code first as data access technology for an Enterprise application.

Can you guys suggest usage of EF code first without above problems?

like image 235
Brainchild Avatar asked Mar 17 '13 12:03

Brainchild


People also ask

Is Entity Framework Good for Enterprise application?

EF is an ORM tool for quickly setting up the code required to map a database to a set of classes in code, and to perform general querying and data management with a direct 'symbiosis' between your classes and your db. It's absolutely possible to use Entity Framework on a large application.

How does code first work in Entity Framework?

Step 1 − First, create the console application from File → New → Project… Step 2 − Select Windows from the left pane and Console Application from the template pane. Step 3 − Enter EFCodeFirstDemo as the name and select OK. Step 4 − Right-click on your project in the solution explorer and select Manage NuGet Packages…

Where does the Entity Framework fits in your application?

As per the above figure, Entity Framework fits between the business entities (domain classes) and the database. It saves data stored in the properties of business entities and also retrieves data from the database and converts it to business entities objects automatically.

Which is better code first or database first in Entity Framework?

Versioning databases is hard, but with code first and code first migrations, it's much more effective. Because your database schema is fully based on your code models, by version controlling your source code you're helping to version your database.


1 Answers

I would strongly recommend against Code First for a large enterprise level application.

Enterprise Level Applications normally have

  • API Projects
  • Multi-web applications / interfaces
  • Synchronization with other data sources
  • Specific optimizations with large datasets.
  • DBA's are involved
  • Large databases start getting Sharded
  • Multi-Continent Deployments
  • SQL Level Security Requirements and Logging
  • and more ...

Data First allows you to take all of this into consideration and not have a database bound by a project.

Code First is great when you have single use applications such as tablet apps or desktop apps or even just for doing quick development. When multiple projects need to access the same database, I would say Code First is no longer suitable.

like image 150
Adam Avatar answered Oct 31 '22 20:10

Adam