Entity Framework Code First Don't Create Table

entity-framework entity-framework-6

Question

I have mapped one of the tables in an existing database I'm utilizing as an object (as I needed to map a foreign key).

Therefore, since this entity already exists, I would prefer EF to disregard it while initializing this database.

How do I approach this?

1
1
6/17/2014 1:27:50 PM

Popular Answer

The first migration you should construct is an empty migration using the-IgnoreChanges checkbox to let Entity Framework to take a snapshot of the current database.

So begin by using:

Add-Migration InitialMigration -IgnoreChanges

and it will alter the Entity Framework information, allowing the current tables to exist unaffected by migrations while also creating a blank migration.

It should be noted that your database schema and the name conventions Entity Framework expects may not be the same. Using the Fluent API, you might need to manually set up the foreign keys.

3
6/17/2014 1:34:14 PM


Related Questions





Related

Licensed under: CC-BY-SA with attribution
Not affiliated with Stack Overflow
Licensed under: CC-BY-SA with attribution
Not affiliated with Stack Overflow