Print Page | Close Window

No datasource key found

Printed From: IdeaBlade
Category: Cocktail
Forum Name: Community Forum
Forum Discription: A professional application framework using Caliburn.Micro and DevForce
URL: http://www.ideablade.com/forum/forum_posts.asp?TID=3969
Printed Date: 15-Apr-2025 at 9:57am


Topic: No datasource key found
Posted By: gregweb
Subject: No datasource key found
Date Posted: 02-Feb-2013 at 2:06pm
I have a Cocktail app set up using the same security structure as TempHire except I am using SQL Server.

When the LogInManager.Login() runs, it throws the error "No datasource key found for this entity type: Security.User.

Yet the datasource key appears to be set up correctly:

In the Security project, there is a App.Config with a connection string name "SecurityEntities" is configured.

The SecurityDBContext has a DataSourceKey attribute set to "SecurityEntities"

When I build the project the Build output shows the connection string is found:

Creating metadata from EntityManager 'SecurityEntities'
1> Searching for connectionString named 'SecurityEntities': found
1> Model metadata created for SecurityEntities
1> Model metadata for SecurityEntities.ibmmx is unchanged

The server log says: LoginException: Unable to login: No datasource key found for this entity type: Security.User

I am not sure what else to look for to resolve.



Replies:
Posted By: kimj
Date Posted: 02-Feb-2013 at 2:15pm
At runtime, DevForce will look for the connection string in the web.config, or the app.config if a 2-tier Windows/WPF app.  So make sure the connection string in your Security project is also in a config used at runtime.


Posted By: gregweb
Date Posted: 02-Feb-2013 at 2:34pm
OK, checked that, and the connection string is in web.config as well:

<add name="SecurityEntities" connectionString="Data Source=.;Initial Catalog=Jet31;Integrated Security= True;MultipleActiveResultSets=True;App=Jet" providerName="System.Data.SqlClient" />

But it still throws the same error.


Posted By: kimj
Date Posted: 02-Feb-2013 at 6:19pm
Do you have a custom IDataSourceKeyResolver?  I'm assuming not, but if so, check what it's doing.  Also check that the .ibmmx is marked as an embedded resource.  And finally, the debug log may have additional information on the processing preceding this error, and may prove helpful.


Posted By: gregweb
Date Posted: 03-Feb-2013 at 6:45am
Thanks Kim. Once I deleted the ibmmx file and let it regenerate, it started working. I think the issue was that I added the DbContext after the original ibmmx file was generated, so that data was missing from it.

Greg


Posted By: kimj
Date Posted: 03-Feb-2013 at 8:51am
Glad you got it working.   The ibmmx should automatically regenerate if any part of the model changes, including the DbContext, so we'll follow up on that to see if there's a problem.



Print Page | Close Window