3

Always in my projects i add a ADO.net Data Model (from database connection) to my Data Access Layer Project that i named it DataProject, but now i need to use SQL Server Databse project that i named it SQLDatabaseProject.

Now, i want how can i make relation between My DataProject and SQLDatabaseProject?

I mean as my old way adding "ADO.net Data Model" from database connection to DataProject and separately i can deploy db or change tables in SQLDatabaseProject!! i want to know is there anyway to make model in DataProject from SQLDatabaseProject? not from my old way?

for more details i used Visual Studio 2012 and i used C# with .net 4.5 and my projects in my solution is like this:

TestSolution

  • SQLDatabaseProject
  • DataProject

and i added reference from SQLDatabaseProject in DataProject but i cant see any namespace of data or something else when i want to create model or ...!!?

Mehdi Yeganeh
  • 2,019
  • 2
  • 24
  • 42
  • Do you means that you wanna do changes in project DataProject, and effect to the SQL DataProject either? – Eugene Jul 16 '13 at 02:06
  • @Eugene tanx for check my question, no.. contrary of you said, i want do changes in SQLDatabase Project and effect to DataProject. – Mehdi Yeganeh Jul 16 '13 at 10:51
  • if I understand you correct you want to update the DataProject model based on SQLDatabaseProject if yes you only need to change the connection string from the ADO.net Data Model from DataProject to point to SQLDatabseProject. – Pedro.The.Kid Jul 18 '13 at 14:35
  • @Pedro.The.Kid, tanQ for comment, yes, you understood great. but what should i set connection string of ado.net data model? i searched in google but i cant find some example of connection string to sql server project..!!?? – Mehdi Yeganeh Jul 19 '13 at 20:30
  • To set the ADO.net Connection string you go to the edmx model right click in an empty area and select properties. NOTE: this is just the EDMX connection string when you run the program it uses the one in your .config file. – Pedro.The.Kid Jul 23 '13 at 10:34
  • @Pedro.The.Kid tanx a lot for help me, i know about how can i change connection string, but what should i set connection string to connect to sql server project?, i googling and nothing found about it.. please write for me true connection string that connect to sql server project not a db ;) – Mehdi Yeganeh Jul 23 '13 at 11:51
  • @MehdiYeganeh sorry I don't know how to connect to a project. – Pedro.The.Kid Jul 23 '13 at 12:24

1 Answers1

2

There are two ways you can do this: 1) You can use T4 templates to generate code for you from the scripts you have in the database project. 2) Have a model and dev database on your machine and then simply do the db changes on model and update those changes on your database project and (Eg. Entity Framework). When you're happy with the changes made to the model database (which should be empty), then publish the changes to the dev database.

Willem Toerien
  • 250
  • 1
  • 3
  • 11
  • tanx for answer to my question,i really need a good answer, i know about T4 or changing model and commit changes in dev db and i know about features, Capabilities or .. of model and sql project, i used both of these projects before but my problem is relation between 2 projects without real db .. i want make changes in sql project and then my model update it from sql project without db, check my question!! i want to know about making relation between these projects not another application like real sql server database or exporting/importing db, if you know something more or my mistakes plz tell – Mehdi Yeganeh Jul 16 '13 at 19:57
  • 1
    Well then in that case you only have my option 1. If I were you, I would then use T4. In a T4 file you can scan through the project and look for the table scripts. From that you create your objects and a data repository. – Willem Toerien Jul 16 '13 at 20:09
  • tanx, i give you upvote for answer and comment, but do you have more details for how could i do this and how can i make T4 script for detect changes in sql server project and fix my model? – Mehdi Yeganeh Jul 16 '13 at 21:47