Joydip
Joydip

Reputation: 41

Code first with existing database migrations new table creation

I have an existing database.I am using code first from existing database.I am able to add new column to an existing table using add-migration and update database command.

But when I want to generate new table using a class new table is not created. For example I want to create a new table LocaleResource.I have created a new class. I have fired add-migration LocaleResourceClass and then Update database command. But no new table is creating.I am using Entity Framework 6.1.

Please help me how to do that.

Upvotes: 0

Views: 433

Answers (1)

Nikolai Manek
Nikolai Manek

Reputation: 1008

In order to have a migration created you have to add the new table to your context.

public virtual DbSet<LocalResource> LocalResources {get; set;}

Otherwise the migration macro does not know about your new table.

In case you are not sure where it was created just search your project for DbSet

Upvotes: 1

Related Questions