How to use the Code First approach for a single table in an existing database that already has many tables

The script . I have an existing database, say, "DemoDB". There are already many tables. These tables are used in my existing application using LINQto SQLor ADO.Net technologies. Now I have a requirement when I have to add a new table "NewTable" in DemoDB and perform a CRUD operation. I want to use the "Code First Approach" for simplicity. I defined a new class for "NewTable" in my application.

Problem . When running my application, it deletes all existing tables for my database. I do not want to create classes for existing tables. Only NewTable remains in my database.

Please suggest if there is any cleaner or easier way to achieve this.

+4
source share
1 answer

I'm not sure if this will work, but you can investigate this more:

Database.SetInitializer<YourDbContext>(null) in the Global.ASAX.

Good luck !!

0
source

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


All Articles