How do I share a database with TFS?

2019-08-31 05:25发布

问题:

I have an ASP.NET project under development with my team. and I want to create a database and share with with my teammates . So that they can make edits (Add table etc). When I open the database thats in the project It give me the following error.

One or more files do not match the primary file of the database. If you are attempting to attach a database, retry the operation with the correct files. If this is an existing database, the file may be corrupted and should be restored from a backup. An attempt to attach an auto-named database for file xxxx.mdf failed. A database with the same name exists, or specified file cannot be opened, or it is located on UNC share.

Please help whats wrong!

at the end of the day, I want a database to share it with a team (or even better I want to host a database somewhere so that all of us can connect to it for FREE)

Please Help!.

Thank you for your time.

回答1:

If you want to share a database, it's better if you create DB project form Visual Studio templates so you can have project that contain all your database objects as files, and by compare your project with your local DB you can merge the change from the DB to the project or from the project to the DB you can also create script for the data that should be exist in the DB and this script can run after deploy your DB project.

So here the scenario, You create a local DB, and you create some tables You create DB project inside your solution You compare the DB with your DB project You write the update of the compare which is some tables files You check-in DB in TFS

Other developer Check-out the solution including DB project Compare the DB project with local DB Write update to the local DB Now the other developer has the same DB

Thanks M.Radwan