0

I have created a project in MVC 3 using code first and nugget , And I would like to clear a few thing before publishing to my shared hosting: In my project I have a class name: IchudShulContext (IchudShul is my project name) In my sql server express it has created a DB name: IchudShul.Models.IchudShulContext.dbo Does it make a different what name I give my shared hosting DB ? Or should it match one of the following : IchudShul / IchudShulContext My local connectionStrings look like this :

connectionString="Data Source=MyPc-MAINPC\SQLEXPRESS;Initial Catalog=IchudShul.Models.IchudShulContext;Integrated Security=True"
     providerName="System.Data.SqlClient" />

Thanks

3 Answers 3

1

Based on Code-First convention, Your ConnectionString name in your web.config should have the same name as your context. Database name is not important. in your scenario, in your web.config:

<connectionStrings>
  <add name="IchudShulContext" providerName="System.Data.SqlClient" 
    connectionString="Data Source=MyPc-MAINPC\SQLEXPRESS;Initial Catalog=WHATEVER_YOUR_DB_NAME_IS;Integrated Security=True" />
</connectionStrings>

If you want to use conventions, make sure the name attribute is: IchudShulContext. That's all. Fill in WHATEVER_YOUR_DB_NAME_IS with whatever you db name is.

Sign up to request clarification or add additional context in comments.

Comments

0

Your shared hosting DB can be named anything.

Your ConnectionString should be updated needs to be updated to point to your database. What that is, you will need to know from your shared hosting provider.

Comments

0

you can name you DB anything, as long as it is valid with respect to your DBMS. the only this that should be matched with your datacontext name is connection name in connection strings section of your web.config file.

Comments

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Start asking to get answers

Find the answer to your question by asking.

Ask question

Explore related questions

See similar questions with these tags.