timabell / ef-enum-to-lookup

Generates lookup tables from enum references in Microsoft Entity Framework 6.1
https://www.nuget.org/packages/ef-enum-to-lookup
69 stars 29 forks source link

Can't create sprocs because lookup tables not in place in time #64

Closed maharatha closed 6 years ago

maharatha commented 6 years ago

I have been using the ef-enum-to-lookup nuget for sometime now and it has been working fine. Recently we have started using stored procedures and views in the system which now uses value from the Enum tables that's created.

Problem : We are deploying the Stored Proc and Views using EF Migration , but the enum tables are being created at the end of the migration on the seed method which doesn't gets called before all database objects are created. This is throwing up error as the enum tables are not there and the views and stoired procedures are referencing those.

Any idea to tackle this

timabell commented 6 years ago

Write a small command line app that references your dbcontext and the lookup generator and spit the generated sql out to a file that you can then put anywhere in your migration workflow.

timabell commented 6 years ago

https://github.com/timabell/ef-enum-to-lookup/blob/98fdc0e5f018ae906d075d89d5b63b75e7748f62/ExampleUsage/EnumExample.cs#L43