I am working on a new application that requires, the creation of DB Views. I am using EF core with MySql flavor and using the Code First approach to create the DB and tables. I didn't find a way to create a view though.If somehow, I could execute the raw sql in migration step, that might help in creation of view and later mapping that as the DbSet. I can't create the views manually as it would require the execution of the view script against the database, and that won't be possible in higher environment. Can someone please guide me. Help is really appreciated!
As far as I know, you can't create views with EF Core directly. However, you can use migrations to execute arbitrary SQL when upgrading.
migrationBuilder.Sql("CREATE VIEW etc.");
migrationBuilder.Sql("DROP VIEW etc.");