Splitting an Solution into multiple projects

2019-09-06 15:41发布

问题:

I created a Black Solution (Arhi) with a ASP.NET MVC 4 Internet project (Arhi.Core) and Class library project for data (Arhi.Data) where I'm storing my EDMX Model.

I added a reference for Arhi.Data into Arhi.Core and I tried to add a Controller with a Model class from Arhi.Data (People entity) and I got this error.

'Unable to retrive metadata for 'Arhi.Core.People'. The specified named connection is either not found in the configuration, not inteneded to be used with the EntityClient provider, or not valid.'

Q : Why did I get this error ? Is my approach wrong / any recommendations? Q2 : If I want to add RDLC reports to my solution, should I also use a Class Library project ?

Connection string from Arhi.Core

<add name="DefaultConnection" providerName="System.Data.SqlClient" connectionString="Data Source=.\SQLEXPRESS;Initial Catalog=aspnet-SalvamontMVC-20121108140556;Integrated Security=SSPI" />

and Arhi.Data

<add name="SalvamontEntities" connectionString="metadata=res://*/ModelSalva.csdl|res://*/ModelSalva.ssdl|res://*/ModelSalva.msl;provider=System.Data.SqlClient;provider connection string=&quot;data source=www.arhimedes.ro,1433;initial catalog=Salvamont;persist security info=True;user id=sa;password=********;multipleactiveresultsets=True;App=EntityFramework&quot;" providerName="System.Data.EntityClient" />

回答1:

in your first connection string not have user name and password if two database deference then give user name and password in first connection string