Invalid object name 'dbo.table_name' when querying STE WCF

Posts   
 
    
nathan.liu
User
Posts: 11
Joined: 09-Jul-2010
# Posted on: 12-Jul-2010 20:55:38   

Hi

I am having problems performing a simple linq query against a STE in my WCF.

I have one table in my DB named 'User_Main' and I have used LLBLGen Pro v3.0 (July 12th, 2010 release) to generate the 2 STE projects (model + persistence).

In my WCF service I have 1 class and 1 method

[ServiceContract] public interface IMyService { [OperationContract] string testFunc(int userID); }

public class myService : IMyService { public string testFunc(int userID) { using (myLlblgenEfv4DataContext context = new myLlblgenEfv4DataContext()) { UserMain userMain = context.UserMains.Where(c => c.Id == userID).SingleOrDefault(); return userMain.EmailAddress; } } }

I have referenced both the model and the persistence projects as well as system.data.entity.

This WCF compiles fine and I can add the service reference to my consuming website. However, when i call the testFunc() form my website I get the following error when it tries to execute my Linq statement:

'An error occurred while executing the command definition. See the inner exception for details.'

going further into the Inner exception i get:

'Invalid object name 'dbo.User_Main''

Looks like there's a mapping issue. Am I doing something stupid in my Linq query? Have I missed a reference? Is there a property that I have not set properly in the designer? I am totally stumped.

Any help woud be appreciated.

Thanks

Otis avatar
Otis
LLBLGen Pro Team
Posts: 39903
Joined: 17-Aug-2003
# Posted on: 12-Jul-2010 22:07:41   

please check the connection string you copied from the generated app.config file to the service' web.config file. It contains 'master' as initial catalog for sqlserver, make that the catalog you want to connect to.

Frans Bouma | Lead developer LLBLGen Pro
nathan.liu
User
Posts: 11
Joined: 09-Jul-2010
# Posted on: 12-Jul-2010 23:39:32   

Great that has solved my problem!

Thank you.