Welcome to OGeek Q&A Community for programmer and developer-Open, Learning and Share
Welcome To Ask or Share your Answers For Others

Categories

0 votes
284 views
in Technique[技术] by (71.8m points)

c# - .NET 4: How to configure EDMX file in other assembly in Web.Config

I have a problem with configuring an EDMX file that lives in an other assembly than by web project. My project looks somewhat like this:

Project 1
--> Database.edmx
--> App.Config

Project 2
--> Ton's of .cs and .aspx files.
--> Web.Config with the proper connection string.

Inside Visual Studio the updating of the .EDMX file inside Project 1 goes smoothly and while I had the .EDMX file inside project 2 the application ran as it supposed to.

Anyone has an idea on how to configure the .EDMX file inside Project 1 to point to the connectionstring of Web.Config? (or should I use Project1.dll.config to configure Project 1?)

See Question&Answers more detail:os

与恶龙缠斗过久,自身亦成为恶龙;凝视深渊过久,深渊将回以凝视…
Welcome To Ask or Share your Answers For Others

1 Reply

0 votes
by (71.8m points)

You have to change the * in the connection string for the assembly name where the .edmx files are in:

<add name="Entities" connectionString="metadata=res://*/Models.EF.Model.csdl|res://*/Models.EF.Model.ssdl|res://*/Models.EF.Model.msl;provider=System.Data.SqlClient;provider connection ... ;" providerName="System.Data.EntityClient" />

for

<add name="Entities" connectionString="metadata=res://Project2/Models.EF.Model.csdl|res://Project2/Models.EF.Model.ssdl|res://Project2/Models.EF.Model.msl;provider=System.Data.SqlClient;provider connection ... ;" providerName="System.Data.EntityClient" />

与恶龙缠斗过久,自身亦成为恶龙;凝视深渊过久,深渊将回以凝视…
OGeek|极客中国-欢迎来到极客的世界,一个免费开放的程序员编程交流平台!开放,进步,分享!让技术改变生活,让极客改变未来! Welcome to OGeek Q&A Community for programmer and developer-Open, Learning and Share
Click Here to Ask a Question

1.4m articles

1.4m replys

5 comments

56.9k users

...