SQL Server versioning integrated into the Entity Framework

Asked

Viewed 95 times

1

In the company I work have chosen to create the models from the database with the Entity Power Tools.

We have an online version of our application and locations for testing and development.

When necessary to change something in the models, we change in the bank and generate the models again... so far so good, we use versioning and everyone gets the same models.

The problem is bank changes, for example:

A VALOR_NOTA field was double now became decimal

Dai we have to make this change in the SQL of all machines.

There is a way to versioning the structure of a table in SQL Server?

  • 1

    It’s not easier for you to use Migrations? Then the database versioning is in the application code.

  • I already suggested with research and evidence, accepted the tip but only after the finalizing of the prospectus. So I will have to wait!

  • Look, there is. The problem is mapping these structural changes. About 5 years ago I wrote a tool in Python that read an SVN repository with the structure and generated the change of version scripts, but it was a lot of work and it was very time consuming. We versioned SQL scripts with the table declaration. That’s what we could do.

  • um... good idea, da para colocar as declarações em um SQL e Versionar dai eu crio uma macro para executar elas a clique já ajuda me! I’ll wait someone might know a way... in case no one shows up as I should close the question?

  • I answer to you. I just wanted to validate some things.

  • @Ciganomorrisonmendez how do I move this conversation to a chat? I would like to ask a few questions about Migrations if possible!

Show 2 more comments

1 answer

1


The best would be to use Migrations, but as the author of the question asked for it not to be possible, I will suggest an alternative solution.

By generating their Migrations, perform a Update-Database immediately with the following command:

Update-Database -Verbose

This will cause the running SQL to be shown in the Console. Save this Log inside some project directory with the extension .sql.

When publishing your project, run the Migrations in order. The result should be very similar to the automated Entity Framework.

Browser other questions tagged

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