0

I keep getting this error on my server when I publish my site - even without changes in database model.

The site is running fine local.

I'm using the DB first approach.

If I delete all files in the site on the server, restore my local database on the server. Publish the site from VS. Sometime it will run fine after that.

If I then make a few changes in the database CONTENT I will get the error.

I don't whant to create any database/tables on the server - just disable the part of the code, that need to do it. In MVC3 we had this DropCreateDatabaseIfModelChanges but I can't see any of that in my current site.

What can I do?

My connectionstring:

    <connectionStrings>
     <add name="GoBagHomeComEntities"     connectionString="metadata=res://*/Models.GoBagHomeModel.csdl|res://*/Models.GoBagHomeModel.ssdl|res://*/Models.GoBagHomeModel.msl;provider=System.Data.SqlClient;provider connection string=&quot;data source=.\sqlexpress;initial catalog=GoBagHomeCom;Persist Security Info=True;User ID=xx;Password=xxxx;MultipleActiveResultSets=True;App=EntityFramework&quot;" providerName="System.Data.EntityClient"
      xdt:Transform="SetAttributes" xdt:Locator="Match(name)"/>
     </connectionStrings>

And my dbcontext

public partial class GoBagHomeComEntities : DbContext
{
    public GoBagHomeComEntities()
        : base("name=GoBagHomeComEntities")
    {
    }
ThorOstergaard
  • 107
  • 2
  • 9

3 Answers3

0

Check dbo.__MigrationHistory if you have records means EF is trying to migrate, so truncate the table and try it again.

if the same thing repeated so you might need to check EF weather it migrates as settings.

have a look to this answer this, you need to have the connection string in web.config file, I think this is the only missed thing.

Community
  • 1
  • 1
Mahmoud Hboubati
  • 1,007
  • 11
  • 26
0

It seems like the problem is solved :)

I'm sure Owin was the bad guy - I was only using it for creating the authentication cookie. Nothing about tables.

After remove all Owin related code on the site it's running.

ThorOstergaard
  • 107
  • 2
  • 9
0

If your bring any change in your database you should follow the following steps:

  1. Update the .edmx file. To update it double click on .edmx when it will open, please right click on a blank space of this file and select "update model from database".
  2. Save and close the file.
  3. Build the project.
  4. Copy .dll file from bin folder and past it where you have hosted your application.