Create a table in an existing database with LINQ to SQL

I have a SQL Express 2008 database that has been broadcast. I would like to create a new table in this database without deleting all existing data in the live database. I created an entity class for the new table and a separate data context.

What is the best way to add a new table using LINQ to SQL

Thanks...

+4
source share
4 answers

This is not a Linq To Sql role in your architecture. You need to create tables before deploying a new version of your data model.

You can manually update your db w / direct SQL commands against it, or you can pack it with a deployment (e.g. using continuous integration scripts or something like Migrator.NET)

+5
source

The new Linq to Entity shipped with Visual Studio 2010 has an easy way to create a database table from the model you created.

here is an example: Create a database using the first model

+1
source

Why not just execute an SQL statement like create table [mytable] ... ?

0
source

Why are you adding unmapped-entities to the chart? I think first you need to create tables after map objects.

0
source

Source: https://habr.com/ru/post/1301930/


All Articles