Search code examples
entity-framework-4.1asp.net-mvc-4membership-provider

Stop EF Database Initialization for DefaultMembershipProvider


Team, I have an ASP.NET MVC application that I'm deploying. When I deploy it the application works fine, but when I call Membership.CreateUser it ends up trying to create the database even though it already exists. What do I need to do to get it so that it will not try to call CreateMembershipEntities since the database already exists?

I've tried Database.SetInitializer to an initializer that does nothing, I've tried removing the defaultConnectionFactory in the Web.config - I'm currently out of options.

I look forward to your help!

UPDATE

I just found out yesterday that the reason it's trying to create the database is because the hosts servers do not allow the connection to query sysdatabases and so the database never exists and is hence always trying to create it. It appears that I may have to go back to the old fashioned AspNet membership provider and also go away from the EF code first model.


Solution

  • give a look here: http://www.qualitydata.com/learn/web-config-membership-provider-settings It shows the Membership configuration section of the web.config. You have to write a similar section and put connectionStringName="Your Connection String". In your connection string you specify the informations of the already existing database.