Sign Up

Sign Up to our social questions and Answers Engine to ask questions, answer people’s questions, and connect with other people.

Have an account? Sign In

Have an account? Sign In Now

Sign In

Login to our social questions & Answers Engine to ask questions answer people’s questions & connect with other people.

Sign Up Here

Forgot Password?

Don't have account, Sign Up Here

Forgot Password

Lost your password? Please enter your email address. You will receive a link and will create a new password via email.

Have an account? Sign In Now

You must login to ask a question.

Forgot Password?

Need An Account, Sign Up Here

Please briefly explain why you feel this question should be reported.

Please briefly explain why you feel this answer should be reported.

Please briefly explain why you feel this user should be reported.

Sign InSign Up

The Archive Base

The Archive Base Logo The Archive Base Logo

The Archive Base Navigation

  • SEARCH
  • Home
  • About Us
  • Blog
  • Contact Us
Search
Ask A Question

Mobile menu

Close
Ask a Question
  • Home
  • Add group
  • Groups page
  • Feed
  • User Profile
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Buy Points
  • Users
  • Help
  • Buy Theme
  • SEARCH
Home/ Questions/Q 8349349
In Process

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: June 9, 20262026-06-09T07:58:04+00:00 2026-06-09T07:58:04+00:00

I am trying to deploy an ASP.NET MVC 4 application with Entity Framework 4.4

  • 0

I am trying to deploy an ASP.NET MVC 4 application with Entity Framework 4.4 to a shared web hosting (GoDaddy-4GH platform). In GoDaddy I can’t create databases using the application code I have to create it via their control panel, which I did.

I want to use the migration feature to allow my database to evolve without manually modify the schema.

I’ve use a combination of IDatabaseInitializer and DbMigrationsConfiguration. The db initializer simply migrates to the latest version.

The problem is that during the update process EF checks whether the database exists using the EnsureDatabaseExists method, and if for some reason it decides that is does not, then it goes ahead and tries to create a new database which of course fails.

  1. How can I debug why the EnsureDatabaseExists returns false?
  2. Is it possible to override this behavior? (from looking at the code with reflection it does not seem that way)

DBMigration implementation

public class DBMigrationInitializaer : IDatabaseInitializer<AppDbContext> {

public void InitializeDatabase(AppDbContext context) {
  bool dbExists;
  var mig = new DbMigrator(new MigrationConfiguration());
  mig.Update();

  Seed(context);
  context.SaveChanges();
}

protected virtual void Seed(AppDbContext context) {
  // TODO: put here your seed creation
}

Exception stack trace

    [SqlException (0x80131904): CREATE DATABASE permission denied in database 'master'.]
   System.Data.SqlClient.SqlConnection.OnError(SqlException exception, Boolean breakConnection) +2072894
   System.Data.SqlClient.SqlInternalConnection.OnError(SqlException exception, Boolean breakConnection) +5061932
   System.Data.SqlClient.TdsParser.ThrowExceptionAndWarning() +234
   System.Data.SqlClient.TdsParser.Run(RunBehavior runBehavior, SqlCommand cmdHandler, SqlDataReader dataStream, BulkCopySimpleResultSet bulkCopyHandler, TdsParserStateObject stateObj) +2275
   System.Data.SqlClient.SqlCommand.RunExecuteNonQueryTds(String methodName, Boolean async) +228
   System.Data.SqlClient.SqlCommand.InternalExecuteNonQuery(DbAsyncResult result, String methodName, Boolean sendToPipe) +326
   System.Data.SqlClient.SqlCommand.ExecuteNonQuery() +137
   System.Data.SqlClient.<>c__DisplayClassa.<DbCreateDatabase>b__7(SqlConnection conn) +38
   System.Data.SqlClient.SqlProviderServices.UsingConnection(SqlConnection sqlConnection, Action`1 act) +98
   System.Data.SqlClient.SqlProviderServices.UsingMasterConnection(SqlConnection sqlConnection, Action`1 act) +349
   System.Data.SqlClient.SqlProviderServices.DbCreateDatabase(DbConnection connection, Nullable`1 commandTimeout, StoreItemCollection storeItemCollection) +315
   System.Data.Objects.ObjectContext.CreateDatabase() +84
   System.Data.Entity.Migrations.Utilities.DatabaseCreator.Create(DbConnection connection) +73
   System.Data.Entity.Migrations.DbMigrator.EnsureDatabaseExists() +76
   System.Data.Entity.Migrations.DbMigrator.Update(String targetMigration) +44
   System.Data.Entity.Migrations.Infrastructure.MigratorBase.Update() +12
   MvcApplication1.Models.MyDBInitializaer.InitializeDatabase(AppContext context) in MyDBInitializaer.cs:31
   System.Data.Entity.<>c__DisplayClass2`1.<SetInitializerInternal>b__0(DbContext c) +75
   System.Data.Entity.Internal.<>c__DisplayClass8.<PerformDatabaseInitialization>b__6() +19
   System.Data.Entity.Internal.InternalContext.PerformInitializationAction(Action action) +72
   System.Data.Entity.Internal.InternalContext.PerformDatabaseInitialization() +186
   System.Data.Entity.Internal.LazyInternalContext.<InitializeDatabase>b__4(InternalContext c) +7
   System.Data.Entity.Internal.RetryAction`1.PerformAction(TInput input) +118
   System.Data.Entity.Internal.LazyInternalContext.InitializeDatabaseAction(Action`1 action) +190
   System.Data.Entity.Internal.LazyInternalContext.InitializeDatabase() +73
   System.Data.Entity.Internal.InternalContext.GetEntitySetAndBaseTypeForType(Type entityType) +28
   System.Data.Entity.Internal.Linq.InternalSet`1.Initialize() +56
   System.Data.Entity.Internal.Linq.InternalSet`1.GetEnumerator() +15
   System.Data.Entity.Infrastructure.DbQuery`1.System.Collections.Generic.IEnumerable<TResult>.GetEnumerator() +40
   System.Collections.Generic.List`1..ctor(IEnumerable`1 collection) +315
   System.Linq.Enumerable.ToList(IEnumerable`1 source) +58
   MvcApplication1.Controllers.EmployeeController.Index() in EmployeeController.cs:21

Thank you,
Ido

  • 1 1 Answer
  • 0 Views
  • 0 Followers
  • 0
Share
  • Facebook
  • Report

Leave an answer
Cancel reply

You must login to add an answer.

Forgot Password?

Need An Account, Sign Up Here

1 Answer

  • Voted
  • Oldest
  • Recent
  • Random
  1. Editorial Team
    Editorial Team
    2026-06-09T07:58:06+00:00Added an answer on June 9, 2026 at 7:58 am

    I have the same problem with my webhost (amen.fr). During SEVERAL days I looked and I realized that there’s something in the implementation of the class DBMigrator and sql server configuring at the host which causes this dysfunction. “System.Data.Entity.Migrations.DbMigrator.EnsureDatabaseExists” unable to check the correct information. That why all transactions with the database are made with my data context. Here is the code that allows me to make semi-automatic migration :

    public class Migrator
      {
        public static void RunMigrations()
        {
          //Configuration configuration = new Configuration();
    
          //configuration.ContextType = typeof(BOContext);//TODO Change to your DbContext
          //configuration.MigrationsAssembly = configuration.ContextType.Assembly;
          //configuration.MigrationsNamespace = "BO.Domain.Migrations";//TODO Namespace that contains your migrations classes
          //configuration.TargetDatabase = new DbConnectionInfo(context.Database.Connection.ConnectionString, "System.Data.SqlClient");
    
          //DbSeederMigrator<BOContext> migrator = new DbSeederMigrator<BOContext>(configuration);
          //migrator.MigrateToLatestVersion();
    
          using (BOContext context = new BOContext())
          {
            Configuration configuration = new Configuration();
    
            configuration.ContextType = typeof(BOContext);//TODO Change to your DbContext
            configuration.MigrationsAssembly = configuration.ContextType.Assembly;
            configuration.MigrationsNamespace = "CodeFirstMembershipSharp.Migrations";//TODO Namespace that contains your migrations classes
            configuration.TargetDatabase = new DbConnectionInfo(context.Database.Connection.ConnectionString, "System.Data.SqlClient");
    
            DbMigrator migrator = new DbMigrator(configuration);
            MigratorScriptingDecorator scriptor = new MigratorScriptingDecorator(migrator);
    
            var lm = migrator.GetLocalMigrations();// get local migration
            var dm = context.Database.SqlQuery<Migration>("select MigrationId from dbo.__MigrationHistory").Select(o => o.MigrationId); // get database migration
            List<string> pm = lm.Except(dm).ToList();// buil and set pending migration
    
            if (pm.Any())// Peding migration exists
            {
              string source = dm.Any() ? dm.OrderBy(o => o).Last() : DbMigrator.InitialDatabase;// get last to set source migration
              string target = pm.OrderBy(o => o).Last(); /// gest last to set target migration
    
              string sql = scriptor.ScriptUpdate(source, target); // buit sql script migration
    
              try { context.Database.ExecuteSqlCommand(sql); } // execute sql script migration
              catch (Exception e)
              {
                string spm = "Pending migrations : " + String.Join(";", pm.ToArray());
                string sdm = "Database migrations : " + String.Join(";", pm.ToArray());
                string[] tmp = { e.Message, spm, sdm, "Source : " + source, "Target : " + target, sql };
    
                throw new Exception(String.Join("\n-----------------\n", tmp));
              }
            }
          }
    
          //// TODO : code seed here
          //Migrator.Seed();
        }
    
        protected static void Seed()
        {
          //using (BOContext context = new BOContext())
          //{
          //  if (!context.Users.Any())
          //  {
          //    MembershipCreateStatus Status;
          //    Membership.CreateUser("Demo", "123456", "demo@demo.com", null, null, true, out Status);
    
          //    if (!context.Roles.Any(o => o.RoleName == "Admin"))
          //    {
          //      Roles.CreateRole("Admin");
          //      Roles.AddUserToRole("Demo", "Admin");
          //    }
          //  }
          //}
        }laguna-veneta
      }
    
    • 0
    • Reply
    • Share
      Share
      • Share on Facebook
      • Share on Twitter
      • Share on LinkedIn
      • Share on WhatsApp
      • Report

Sidebar

Related Questions

i am trying to deploy simple asp.net mvc frameworkd application in may shared hosting
I've been trying to deploy my ASP.NET MVC 3 Beta Application to my hosting.
I am trying to deploy an ASP.NET 3.5 Web Application to my production server
I'm building an ASP.NET MVC application and I'm trying to deploy it on a
I am trying to deploy a asp.net mvc site. My hosting service provider provides
I've built an MVC 2 application (ASP.net 3.5) using Entity Framework, and am doing
I'm trying to deploy ASP.NET MVC 3 application wich uses Unity as a IoC
I am trying to deploy a test ASP.NET MVC site to a site hosted
I'm trying to deploy an ASP.NET MVC 2 app using MsDeploy. I use VS2010
I'm trying to deploy my new ASP.NET MVC 2.0 website to our Windows Server

Explore

  • Home
  • Add group
  • Groups page
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Users
  • Help
  • SEARCH

Footer

© 2021 The Archive Base. All Rights Reserved
With Love by The Archive Base

Insert/edit link

Enter the destination URL

Or link to existing content

    No search term specified. Showing recent items. Search or use up and down arrow keys to select an item.