Click here to Skip to main content
15,886,652 members
Please Sign up or sign in to vote.
0.00/5 (No votes)
See more:
Trying to convert classroom code to my hosting site.

I'm having a tough time reasoning this out, I am relatively new to .NET MVC 4 and working in a somewhat restrictive environment on a "WinHost" server and playing within their rules.

The hosing site rules are: they assign you a server address (no problem)like 10.2400.thisServer.com, they then prefix all database names with something like "USER_5777" + (my 5 char name). They require security to be "Integrated Security=False"

I am doing online MVC learning and have no problem with the local tasks and operation of the classroom code. But, I want to adapt these tasks and example projects to a real-time environment on my web host site, "WinHost" is who I use.

All classroom code assumes Microsoft SQL Server and local IIS below is an example of the current "web.config" that works perfectly locally.
C#
"<add name="MvcAuction.Models.AuctionsDataContext" connectionString="Data Source=(LocalDb)\v11.0;Integrated Security=SSPI;AttachDBFilename=|DataDirectory|\MvcAuction.Models.AuctionsDataContext.mdf" providerName="System.Data.SqlClient" />


As you can see it is an attached mdf in the "App_Data" folder

Here is the modified version of my "web.config" on the host.
C#
<add name="MvcAuction.Models.AuctionsDataContext" connectionString="Data Source=tcp:g09.winhost.com;Initial Catalog=DB_12345_auction;User ID=DB_12345_auction_user;Password=MonkeysUncle;Integrated Security=False;" providerName="System.Data.SqlClient" />


I have created a database on the host site according to their rules as I pointed out above. But it errors out the program with {"Model compatibility cannot be checked because the database does not contain model metadata. Model compatibility can only be checked for databases created using Code First or Code First Migrations."}

Please Help
Posted
Updated 7-Aug-15 10:45am
v3
Comments
Joan Magnet 6-Aug-15 6:04am    
Take a look at this:

http://stackoverflow.com/questions/14064434/ef5-getting-this-error-message-model-compatibility-cannot-be-checked-because-th
sreeyush sudhakaran 10-Aug-15 7:43am    
Refer http://www.connectionstrings.com/

1 solution

If you are not using Code First Approach, Disable the initializer
C#
public class YourDbContext: DbContext 
    {
        public YourDbContext() : base("MvcAuction.Models.AuctionsDataContext")
        {            
            //Disable initializer
            Database.SetInitializer<yourdbcontext>(null);
        }
        
    }

Hope this helps
 
Share this answer
 
v3
Comments
aarif moh shaikh 11-Aug-15 0:48am    
Agree with you

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