0

I feel like this is pretty easy but how do I add a reference to my newly created DB project in my solution? I have my WPF application in one project and the DB in the other, how to I go about utilizing this DB in the WPF project? When I click "Add database Reference..." the option to select a database in the same solution is disabled.

Thanks!

marc_s
  • 732,580
  • 175
  • 1,330
  • 1,459
cskwrd
  • 2,803
  • 8
  • 38
  • 51
  • 1
    What do you mean by "utilizing this DB in the WPF project?" Are you just trying to write queries against it? Or make an Entity Framework data model? – Joe Enos Oct 29 '13 at 22:08
  • I'm sorry I am coming from a PHP background here. But you are correct, I want to store objects in the database I have defined in my database project. I would prefer to write as few actual SQL queries as possible. That is what the Entity Framwork data model will do for me correct? – cskwrd Oct 29 '13 at 22:17

1 Answers1

0

With Entity Framework (database-first model), you don't add a reference to a database project, but instead to an actual database. In your WPF project (or a separate library), Add New Item, and select ADO.NET Entity Data Model.

From there, it will walk you through the steps of choosing the database to build your data model from, along with which objects you want to bring in.

But before you do that, you have to publish the database somewhere, to a real SQL server (can be your local dev machine, and can be SQLEXPRESS or possibly localdb). Then when you add the EF model, you'll have a connection to point to.

Once your Entity Framework model is up and running, you shouldn't have to write any SQL (assuming you're just doing relatively simple CRUD operations).

Joe Enos
  • 39,478
  • 11
  • 80
  • 136