Click here to Skip to main content
15,906,569 members
Please Sign up or sign in to vote.
0.00/5 (No votes)
See more:
I have a DataContext and I have a name of existing database
I want to create all tables that DataContext contains to the database

What I have tried:

I have created a new database from the DataContext but I want to do that to an exist database

C#
 DataContext db =new DataContext("Data Source=localhost\\sqlexpress;Initial Catalog=db;Integrated Security=True");
db.CreateDatabase();
Posted
Updated 11-Jul-16 3:55am

If you're using Entity Framework, Google for "Code First Migrations".

If you're using just the straight classes from the System.Data.Linq namespace, you have to execute the SQL queries to create the tables yourself.
 
Share this answer
 
Hi please go through this link to clear your concept. See Part 2 in this link to solve your query.

How to Use LINQ to SQL in C Sharp (with Pictures) - wikiHow[^]
 
Share this answer
 
v2

This content, along with any associated source code and files, is licensed under The Code Project Open License (CPOL)



CodeProject, 20 Bay Street, 11th Floor Toronto, Ontario, Canada M5J 2N8 +1 (416) 849-8900