Entity Framework 5 always try to connect to sqlexpress instead of local db

I'm using Visual Studio Express for web to follow this tutorial http://msdn.microsoft.com/en-US/data/jj193542. The tutorial tells that

By convention DbContext has created a database for you.

If a local SQL Express instance is available (installed by default with Visual Studio 2010) then Code First has created the database on that instance If SQL Express isn't available then Code First will try and use LocalDb (installed by default with Visual Studio 2012) The database is named after the fully qualified name of the derived context, in our case that is CodeFirstNewDatabaseSample.BloggingContext

So, it should use localdb. But when I try to access my model, I can see in debug that the connection string points to .SQLEXPRESS, althought I don't have sqlexpress. So, I got a timeout exception ...

Why localdb isn't used ?

Note that if I set explicitly the connectionstring to localdb, it's working ... Note too, that if I use Vs Express for Desktop, it's working too...

What's wrong with the Vs Express for web ?


EF Connections解释说明EF默认使用工厂,例如

<entityFramework>
<defaultConnectionFactory type="System.Data.Entity.Infrastructure.SqlConnectionFactory, EntityFramework">
  <parameters>
    <parameter value="Data Source=.; Integrated Security=True; MultipleActiveResultSets=True" />
  </parameters>
</defaultConnectionFactory>

链接地址: http://www.djcxy.com/p/71330.html

上一篇: WinAPI调用访问没有驱动器号的USB存储器?

下一篇: 实体框架5总是尝试连接到sqlexpress而不是本地数据库