I have a SQL Server database project with definition of tables, relations, keys, indexes, security, publish profiles, etc. and I also have an ASP.NET Core MVC project.
The issue is that I would like to use Entity Framework for DML operations but the catch is that I am allowed to use only stored procedures (probably from the security perspective, where application account will have only execution permission on those stored procedures and read only on specific tables).
I found that EF can map .SaveChanges()
method to stored procedures via model builder like this example
modelBuilder.Entity<SubjectArea>().MapToStoredProcedures();
From the MS docs https://learn.microsoft.com/en-us/ef/ef6/modeling/code-first/fluent/cud-stored-procedures
It can also generate them with migration
command. I am not experienced with migrations, but I would like to only generate the SQL for the stored procedures creation and add this script (which was not run yet) into the SQL Server database project (the workaround is to run migration into separate database and generate scripts from the database into the database project, but it seems not nice).
Is it possible to do it somehow?