0

I am creating a database with Entity Framework 4 and Visual Studio 2010.

I am fine with the first steps - I am going model first, so I successfully created the model and now there is a valid .edmx file in my solution.

My goal is the following: I want to generate the database and add it to the solution so I can give the solution to another person and they will be able to build it and run it - I do not want the database connection be dependent on any of my local settings, and I do not want them to have the need to recreate the database, it will have some 'seed data' in it. That should be possible, I saw similar solutions.

I would appreciate advice on how to do that.

abatishchev
  • 98,240
  • 88
  • 296
  • 433
Evgeny
  • 3,320
  • 7
  • 39
  • 50

1 Answers1

1

Use SQL Server Express and put database files to App_Data directory (for web application) or make them solution items copied to output for other application. Change connection string to attach the file - it should look something like:

AttachDbFileName=|DataDirectory|\YourDB.mdf;Initial Catalog=YourDB;Integrated Security=SSPI
Ladislav Mrnka
  • 360,892
  • 59
  • 660
  • 670
  • OK, I can add an existing database file. That bit works. Can I create it from the model in the same solution? If I create a database from the model, and then add it to the solution, it adds a new model file and will I be able to update database from model after? – Evgeny Oct 13 '12 at 10:05
  • Anyway, I think database first approach turned out to be quite suitable for my needs. – Evgeny Oct 15 '12 at 11:20