4

I am using EF Code First with DontDropDbJustCreateTablesIfModelChanged.

I am using this because I am deploying to Appharbor, and this way only the tables are drop/recreated and not the database.

In the same database I used the aspnet_regsql tool to genarate tables for Membership and Role provider.

How can I make EF Code First to drop/Recreate the tables from my project, and not the ones for 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

1 回答 1

4

Implement your own IDatabaseInitializer with your own custom logic to exclude these tables (or just not include them) See an example here: https://gist.github.com/895730

于 2011-12-28T21:30:49.777 回答