Assaf Our
Assaf Our

Reputation: 639

publishing Db after creating using EF Code first

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

Upvotes: 0

Views: 285

Answers (3)

Abdul Qadir Memon
Abdul Qadir Memon

Reputation: 1019

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.

Upvotes: 0

Kamyar
Kamyar

Reputation: 18797

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.

Upvotes: 1

Daryl Teo
Daryl Teo

Reputation: 5495

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.

Upvotes: 0

Related Questions