0

I have a .net core 2 project, along with Entity framework Core.

I have an existing database, and I've mapped them out to database entities in code.

The problem is that when I add a migration, expectedly it picks up my entity as a new table, however it is an existing table. The table shares the same name.

I suppose, I could just remove the contents of the Up method of the migration, but I want to know if there is a proper way instead of a workaround.

So, what I am asking is how can I tell entity framework core that this table is already existing?

1 Answer 1

2

EF 6 had an -IgnoreChanges option that would just take a snapshot with no Up() code, but that feature is not in EF Core (yet). See here.

If you comment out the Up() code as you have suggested that will indeed capture a snapshot of your existing objects and subsequent migrations will be incremental.

Sign up to request clarification or add additional context in comments.

Comments

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Start asking to get answers

Find the answer to your question by asking.

Ask question

Explore related questions

See similar questions with these tags.