I'm using an existing database and I have mapped one of the tables as an entity (as i needed to map a foreign key).
So when it comes to initialising this database I would like EF to ignore this entity since it already exists.
How would I go about doing this?
You should create an empty migration as the first migration with the
-IgnoreChanges flag to allow Entity Framework to get a snapshot of the existing database.
So out of the gate use:
Add-Migration InitialMigration -IgnoreChanges
and that will create a blank migration but it will update the Entity Framework metadata allowing the existing tables to exist and not be touched by migrations.
Also to be mentioned that the naming conventions that Entity Framework expects and your database schema may differ. You may need to manually setup the foreign keys using the Fluent API.