3

I have been developing an application over the last few months using EF code first approach with SQL Server Express. It has been great but now I am ready to deploy my application to a live server I need to be able to begin using EF with a standard SQL Server Management Studio database.

I have scripted the db from my personal instance of SQL Server Express and created the db on the live server via management studio. I have also copied the data from the EdmMetadata table to the live db.

Will I be able to continue using DbContext the same way as before and simply change the connection string? I assume I won't so what are the issues facing this?

1 Answer 1

3

YES OF COURSE!

SQL Server (Express or Standard or Enterprise editions) are absolutely 100% binary compatible - SQL Server Express IS a full-blown SQL Server edition, same code-base as the other editions, only with some "artificial" (marketing-induced) limitations....

You could even create a BACKUP from your SQL Server Express (to a .bak file) and restore that back onto a "full-blown" SQL Server edition - works flawlessly.

And YES - EF can absolutely connect to a full-blown SQL Server, too - with all three coding approaches (database-first, model-first, code-first). All you need to change is your SQL Server connection string that you have stored somewhere.

Sign up to request clarification or add additional context in comments.

6 Comments

Done it and my god I cannot actually believe it was so simple to do! I was preparing myself for a long hard slog!
If you are going be using it as a production environment make sure you remove metadata tracking from the database conventions after you initially deploy or you may end up with an empty database when you make a future change to the model
@Chris thanks for the tip what does Metadata Tracking actually do?
@marc_s if I try to connect to the live db from an instance of the application running from my local machine I get this error even though I haven't changed the model: "The model backing the 'EkmDomainsDbContext' context has changed since the database was created. Either manually delete/update the database, or call Database.SetInitializer with an IDatabaseInitializer instance" do you have any idea why??
metadata tracking keeps a small table in the database with some hash data to detect when the model has changed which signals code first to regenerate the database removing the convention turns off the feature in a future version of entity framework they are adding migrations which will allow you to do incremental db development (its currently available in alpha stage) so that it will attempt to do alters instead of dropping and recreating the database till then i would leave metadata off in your production database
|

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Start asking to get answers

Find the answer to your question by asking.

Ask question

Explore related questions

See similar questions with these tags.