EntityFramework.Docs icon indicating copy to clipboard operation
EntityFramework.Docs copied to clipboard

Document flowing annotations through the model to migrations

Open ajcvickers opened this issue 7 years ago • 2 comments

Specifically to show how the model can be annotated, the model differ can diff those annotations, and migrations operations can be created.

ajcvickers avatar Jan 09 '18 16:01 ajcvickers

The first thing I'd like to see is how to prioritize object creation or specify dependencies. When generating the SQL script, the SQLGenerator will create table objects and then create foreign key constraints. However, when creating views, the body of the SQL will have dependencies on underlying tables or views. How can we provide this hint to EF?

In the customcodegenerator, I can change a CreateTable statement to a CreateView statement by testing for my new annotation IsViewAttribute. I can then extend m SQLGenerator to handle CreateView. What I don't see is how to specify that the table Zoologists needs to exist before the view vwSpecialists; and that, uspAuditData needs to exist before creating any table object with an Instead of Trigger. example: migrationBuilder.CreateProcedure(ProcedureType.StoredProcedure,"audit.uspAuditData"); migrationBuilder.CreateProcedure(ProcedureType.InsteadOfInsert,"dbo.customers"); migrationBuilder.DependencyMap.Add("dbo.customers","audit.uspAuditData");

update-database -script outputs in alpha order.

kroleigh avatar Jan 09 '18 20:01 kroleigh

See https://github.com/dotnet/efcore/issues/34454#issuecomment-2540347202

AndriySvyryd avatar Dec 13 '24 01:12 AndriySvyryd