开发者

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


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.


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.


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.

0

上一篇:

下一篇:

精彩评论

暂无评论...
验证码 换一张
取 消

最新问答

问答排行榜