Click here to Skip to main content
15,888,351 members
Please Sign up or sign in to vote.
1.00/5 (1 vote)
See more:
I have A problem in update-database Code-First in project asp.net mvc
i add-migration and it's Done
but when i update database the error is shown to me
"Instance Failure"
and i need your help

What I have tried:

C#
my dbContext Class
    public class MyDbContext:DbContext
    {
   
        public DbSet<organization> Organization { get; set; }
        public DbSet<outlet> outlets { get; set; }
        public DbSet<employee> Employees { get; set; }
        public DbSet<expensedetail> ExpenseDetails { get; set; }
        public DbSet<expensecatagory> ExpenseCatagories { get; set; }
        public DbSet<expense> Expenses { get; set; }
        public DbSet<expenseitem> ExpenseItem { get; set; }
        public DbSet<incomevm> IncomeVm { get; set; }
        public DbSet<item> Item { get; set; }
        public DbSet<itemcategory> ItemCategories { get; set; }
        public DbSet<party> Party { get; set; }
        public DbSet<purchase> Purchase { get; set; }
        public DbSet<purchasedetail> PurchaseDetails { get; set; }
        public DbSet<sale> Sale { get; set; }
        public DbSet<salesdetail> SalesDetails { get; set; }
        public DbSet<stockvm> StockVm { get; set; }

    
    }
}


my Connection string is :

<connectionstrings>
    <add name="MyDbContext" connectionstring="Integrated Security=true;Initial Catalog=ERPapp;Data Source=DESKTOP-VTLRB7T\\SQLEXPRESS;" providername="System.Data.SqlClient">
Posted
Updated 22-Jul-20 21:32pm
v2
Comments
Richard Deeming 24-Jul-20 7:04am    
Don't try to paraphrase error messages. Just paste the entire error message into your question, making sure to censor any private details like passwords.

1 solution

Check for these:

1. There might be an error with your SQL Server instance..

Make sure your SQL Server instance(MSSQLSERVER) is running. To check in services list:
a. open run dialog box and type: "services.msc" (without quotes) and hit Enter.
b. services management console opens up - check whether your instance in running or not.

2. Try to change your connection string section in web.config to look like:

HTML
<connectionstrings>
    <add name="MyDbContext" connectionstring="Data Source=DESKTOP-VTLRB7T\SQLEXPRESS;Initial Catalog= ERPapp;Integrated Security=true;" providername="System.Data.SqlClient"></add> 
</connectionstrings>

3. If the problem still persists, then try using: Data Source=.\SQLEXPRESS instead
 
Share this answer
 

This content, along with any associated source code and files, is licensed under The Code Project Open License (CPOL)



CodeProject, 20 Bay Street, 11th Floor Toronto, Ontario, Canada M5J 2N8 +1 (416) 849-8900