Modeling with Code First so you can exchange databases

Asked

Viewed 155 times

6

If I generate my database for Mysql using the concept of Code First is it possible to change it to SQL Server in the future with relative ease? Need to change the classes or just the config and the preview?

  • 1

    As far as I know, the Entity Framework abstracts the database completely. Changing the database should be as simple as changing the connection string on the web.config (and referencing the DLL’s that have the correct providers).

  • I thought about it. If that’s all it is.

  • Using Code First your classes generates the bank, is how it was done in Clipper, will create the tables and fields according to the need of the system, can even be productive but I think bad this.

  • When modeling the database you have an overview of the system, the relationships, if it can meet the needs, reports and possible problems, you already part to the programming with a ready model.

  • As to using more than 1 bank, if you use ORM it will take into the system the particular characteristics of each bank, not as simple as migrating bank and will need to maintain more than 1 version of the system,

  • the advantages of using ORM disappear with increasing complexity as it is necessary to promote a break of abstraction by forcing the developer to handle SQL.

  • All I know is that calling EF "garbage" can only be a compliment to EF...

Show 2 more comments

1 answer

6


The idea of the Entity Framework is this, you develop in a way independent of the database. It even has some facilities to make the migration.

This is not to say that any code you make will be well exchanged without major problems. In basic the transition should be smooth. If you start doing very customized operations using very specific things from a database that cannot be easily reproduced by another bank then you may have performance problems or even not function as expected.

In general the model does not need to be changed at all, but it may need some adaptation. A very good index in one database may not be as suitable in another. The physical structure in one DB may not be ideal in another. It doesn’t mean it won’t work, but adaptations will help. Queries and manipulations may need more adaptations to get everything in order.

The quality of preview from the database to the Entity Framework can make a difference.

  • Show. As you said I understand that there must be specific situations that may require a little more change but if overall the RU manages to solve most cases I intend to follow this path. I haven’t chosen Provider yet, but the idea is to start with Mysql and soon migrate to Sqlserver and see how it behaves. Thank you

Browser other questions tagged

You are not signed in. Login or sign up in order to post.