0

I have created a new MVC3 project and used the ADO.NET Entity Data Model to map out my existing database. It worked great.

Now, that is a database I don't want to affect when doing development of my web app, so I was looking to now attach that data model to a local database (haven't selected one yet, suggestions welcome. I was thinking SQL Server CE or MySQL).

Does anyone have any ideas on how to do this? I'd be nice to keep the existing connection string to my live database as well as this development database environment.

2
  • Can you not just change the connection string in the web/app.config file to meet the new database? Commented May 17, 2012 at 20:30
  • you can use the Web.Release.config and Web.Debug.config to override the default connection properties inside the web.config. i'll look up what I've done before and add as an answer Commented May 17, 2012 at 20:56

3 Answers 3

1

You can generate another matching DB using whatever technology you want (though it would be good to keep them similar to your production DB) and then have a Web.Debug and a Web.Release setup.

If you look at swapping out the configuration, connection string portion of your web.config file you can easily swap from development to production.

http://msdn.microsoft.com/en-us/library/dd465326.aspx

This provides the relevant information for the transform statements in your Web.config file, but from the sounds of it you can simply swap the connection portion of your web.config and get what you want.

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

3 Comments

+1 mark, pretty much along the lines of what i was gonna put, but got nothing much to add, so yours stands :)
Interesting link about the Web.Config. I am used to writing Windows Services -- not much in the web space, so this bridges the gap for me. I was hoping to leverage some of the tools within EF to automatically re-generate the classes for use from the model created by the 'production' environment, but this should be sufficient.
I'm not clear what you mean here: "re-generate the classes for use from the model created by the 'production' environment". In your original post it sounded like you were doing model first development, but then this statement sounds like you are doing database first development. Maybe you wanted to initially do model first, deploy to production, and from then on always make changes in production, essentially flipping to a database first method. This is possible if that's what you desire(I've actually done this before because I trust my ability to modify the production system more than EF).
0

Is the existing database on your machine, or on a server somewhere?

If it's on your machine, just back it up and restore it to a different database; i.e. if your database is called XYZ, back it up and restore it to a database called XYZ-Testing. You can then connect to and use XYZ-testing without affecting XYZ.

If the existing database is on a server somewhere, the easiest solution is to install SQL Express on your machine, and then backup the database on the server and restore it on your machine.

Doing this will make your life much easier than trying to use a different database type (SQL CE or MySQL).

Comments

0

Another option would be to use SQL Server Data Tools (SSDT) free download, add-in to VS or stand-alone if no VS, and then to create a local database project for development. I wrote a blog post about using SSDT as well.

Comments

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.