How to determine the EF code. First, you need to delete only those tables that are defined in DbSet, and not others (Memberhisp tables) in the same database?

I am using EF Code First with DontDropDbJustCreateTablesIfModelChanged .



I use this because I am deploying to Appharbor, and thus only drop / rereated tables, not the database.



In the same database, I used the aspnet_regsql tool to generate tables for the membership provider and role.

How can I make EF Code First to delete / recreate tables from my project, and not for the membership / role provider?

This is the error I get:

 Cannot use DROP TABLE with 'vw_aspnet_Applications' because 'vw_aspnet_Applications' is a view. Use DROP VIEW. Cannot use DROP TABLE with 'vw_aspnet_Users' because 'vw_aspnet_Users' is a view. Use DROP VIEW. Cannot use DROP TABLE with 'vw_aspnet_MembershipUsers' because 'vw_aspnet_MembershipUsers' is a view. Use DROP VIEW. Cannot use DROP TABLE with 'vw_aspnet_Roles' because 'vw_aspnet_Roles' is a view. Use DROP VIEW. Cannot use DROP TABLE with 'vw_aspnet_UsersInRoles' because 'vw_aspnet_UsersInRoles' is a view. Use DROP VIEW. drop table [vw_aspnet_Applications] drop table [vw_aspnet_Users] drop table [vw_aspnet_MembershipUsers] drop table [vw_aspnet_Roles] drop table [vw_aspnet_UsersInRoles]] 
+4
source share
1 answer

Deploy your own IDatabaseInitializer using your own logic to exclude these tables (or just not include them) See Example: https://gist.github.com/895730

+4
source

Source: https://habr.com/ru/post/1388377/


All Articles