Skip Navigation Links
C# Corner Home
Forum Home
Latest 50
Unanswered
Win Prizes
All Time Leaders
Jump to CategoryExpand Jump to Category
Login 
    Welcome Guest!
 Search Forum For :  
X
 Login
Please login to submit a new post, reply and edit exiting posts, see user profiles, and access more features. If you are not a registered member, Register here.
User Id / Email:
Password:  
Forgot Password | Forgot UserName
   Home » .NET 3.0/3.5 » Problem with Entity Framework inside of Class Library
       
Author Reply
Arshad
posted 317 posts
since Dec 18, 2007 
from India

Problem with Entity Framework inside of Class Library

  Posted on: 27 Aug 2010       

Hi All,
I have one class library project with Entity framework. while addind the Entity modal. the framework does generate the connection string in the App.config. After adding this class library in any other Win or web application. i am getting error like its not able to open the connection,after that i copied and pasted the same coonection string from the Class library project to the WinApplication,then it was working fine. so it means connection string is getting reference from the Configuration file of client application. i googled and found that it does work like that. but my requirement is i need to get the connnection string from the class library Application.
Before using the Entity Framework i had the same requirement, that i was able to do. I added the Connection string in side the settings of class library and was able to acess and was working nicely. but in Entity Framework i tried to apply the same logic and changed the modified the auto generated Partial class for EDMX. connection string is fetching from the settings of class library, but its giving error. i dont know that how It does take care. Any suggestion will be helpful for me.
Regards,
Arshad
Mahesh Chand
posted  3806 posts
since  Oct 29, 2004 
from  Philadelphia

 Re: Problem with Entity Framework inside of Class Library
  Posted on: 27 Aug 2010        0  
It looks like you're missing connection string reference. Did you try to search references everywhere in the solution including resource files? I have not dealt with Entity Framework but problem seems to be simple. Just try to find all connection string references.
Admin

Arshad
posted  317 posts
since  Dec 18, 2007 
from  India

 Re: Problem with Entity Framework inside of Class Library
  Posted on: 27 Aug 2010        0  
Hi Mahesh,

I am not missing the connection string reference. i am able to get the connection string, coz i have defined the connection string inside the settings of the class library. so i can access with the settings property.
Normally when we add the Data Model in the project that time it does generate the connection string with the meta data. Once i had used the entity framework with the wcf that time we also add the same connection string inside the web config file of wcf, so run time gets take care. but here i dont want that connection string to be added in the client application. i want to override the connection string in side the entity framework class,
While adding data model, it generates one partial class, that class is having the constructor with the connection string. i modified but its not able to get the reference. thats my problem.

In my very first comment also i mention, like if u will try to acess the connection string or like path of the project, it does not work with the class library. it takes the reference from the client application. for that i added the connection string in side the settings of the class library. then it was working.

Entity framwork connection string is also different, it gets generate with the meta data with the consaptual layer, data layer and mapping layer. i dont know that how entity framework acess that connection string. i googled and found that people having the same requirement like me, but they got suggestion to use the connection string in side the client application also.

Regards,
Arshad
       
Discover the top 5 tips for understanding .NET Interop
Dynamic PDF
ceTE software specializes in components for dynamic PDF generation and manipulation. The DynamicPDF™ product line allows you to dynamically generate PDF documents, merge PDF documents and new content to existing PDF documents from within your applications. Visit DynamicPDF here
Discover the Top 5 .NET Memory Management Fundamentals
To write the best .NET code, you need to know exactly how the .NET framework really manages memory. Ricky Leeks presents the Top 5 fundamental facts of .NET memory management. Learn more.
Introducing MaxV - one click. infinite control. Hyper-V Hosting from MaximumASP.
Finally – a virtual platform that delivers next-generation Windows Server 2008 Hyper-V virtualization technology from a managed hosting partner you can truly depend on. Visit www.maximumasp.com/max for a FREE 30 day trial. Hurry offer ends soon. Climb aboard the MaxV platform and take advantage of High Availability, Intelligent Monitoring, Recurrent Backups, and Scalability – with no hassle or hidden fees. As a managed hosting partner focused solely on Microsoft technologies since 2000, MaximumASP is uniquely qualified to provide the superior support that our business is built on. Unparalleled expertise with Microsoft technologies lead to working directly with Microsoft as first to offer IIS 7 and SQL 2008 betas in a hosted environment; partnering in the Go Live Program for Hyper-V; and product co-launches built on WS 2008 with Hyper-V technology.
Nevron Chart for .NET 2010.1 Now Available
The leading .NET charting control now features PDF, Flash and Silverlight export, visualization of large datasets and more. Deliver true charting functionality to your BI, Scorecard, Presentation or Scientific apps. Download evaluation now.
ASP.NET 4 Hosting
Get 2 Months Free of ASP.NET Hosting for Only $4.95/month! Receive FREE MS SQL and MySQL Databases Including ASP.NET 4/3.5, MVC 3.0, Silverlight 4, Windows 2008/IIS 7.0 Plus FREE IIS 7 Modules. Host UNLIMITED ASP.NET Web Sites – Click Here!
Nevron Chart
 Hosted by MaximumASP  |  Found a broken link?  |  Contact Us  |  Terms & conditions  |  Privacy Policy  |  Site Map  |  Advertise with us
Current Version: 5.2011.3.12
 © 1999 - 2012  Mindcracker LLC. All Rights Reserved