0

I want to place Entities and Database (here I used Sql Serve Ce) in a project, and use them in another project in the same solution.

I have problem setting the database location this way and the context is always null

Project One will have all the database , ConnectionString and entities

Project Two is the User project of the Entities defined in Project One

This is a Windows Forms Application And the name of the Entity Connection Name is dbEntitties

The database is in the root of the application folder

This was a sample connection string I had :

<add name="dbEntities"
 connectionString="metadata=res://*/dbModel.csdl|res://*/dbModel.ssdl|res://*/dbModel.msl;provider=System.Data.SqlServerCe.3.5;provider connection string=&quot;
 Data Source=|DataDirectory|\db.sdf;Password=xxxxxxx;Persist Security Info=True&quot;" providerName="System.Data.EntityClient" />

-- The project will work as it is expected if I place the database and entities in the same project, But placing them in a different project and referencing the that project wouldn't help, I got no errors but the context will remain null.

Any Ideas ?

4

1 回答 1

1

好的,所以从上面的评论中,我们已经确定了原因是它没有获取配置,因为您已将它与数据库一起放在根目录中。

配置只会被入口点拾取。将它放在 Windows 窗体中应该可以解决此问题。

于 2012-06-10T11:47:00.897 回答