Frustrating error

Posts   
 
    
zbussinger
User
Posts: 3
Joined: 29-Aug-2006
# Posted on: 29-Aug-2006 17:38:47   

Hi all, I am using LLBLGen at work for a data migration application. The application was done and working, but we decided to regenerate the code (for naming convention reasons, and to switch to the adapter method) and change around where things were in source control a bit.

After re-generating and putting everything back together, and fixing my code, my program builds just fine but there is a problem with the data access adapter. I have a feeling it is a reference issue, but i can't figure it out. All of the proper .dll files are being referenced in my project.

The error occurs whenever i try to save an entity; for example if i do something like:

AddressEntity myAddressEntity = new AddressEntity(); // Set all of the properties needed for the entity DataAccessAdapter adapter = new DataAccessAdapter(); adapter.SaveEntity(myAddressEntity);

I get this error:

The element name 'AddressEntity' isn't known in this provider Parameter name: elementName

I don't get it.... everything looks fine to me. And like i said, the solution builds just fine. I am using SQL Server 2005, and C# (.NET 2.0) with the adapter method of LLBLGen.

Thanks!

-zach

Jessynoo avatar
Jessynoo
Support Team
Posts: 296
Joined: 19-Aug-2004
# Posted on: 29-Aug-2006 17:51:29   

Hi,

did you make sure that the dataaccessadapter corresponds to the correct dbspecific dll?

I guess in such a migration scenario you should have two types of adapter, right?. It may be that the wrong adapter gets instanciated (I had the problem once, not so obvious to tell). Please check the references again and explicit the complete namespace if needed.

zbussinger
User
Posts: 3
Joined: 29-Aug-2006
# Posted on: 29-Aug-2006 18:02:02   

everything looks ok in that regard. I am actually only using one adapter; basically reading from an old table using ADO.net and adding to the new table. I just don't know what's going on... we re-organized things in the projects a little bit, but it was working just fine before. Ugh, it's hard to even be specific cause i'm so clueless rage

Any other ideas?

Jessynoo avatar
Jessynoo
Support Team
Posts: 296
Joined: 19-Aug-2004
# Posted on: 29-Aug-2006 18:24:34   

Sorry to insist but it has to be something related to a wrong dbspecific project/reference:

To make it clearer:

In your dbspecific project, you should have a PersistenceInfoProvide with functions that look like:

Private Sub InitAddressEntityMappings()
            MyBase.AddElementMapping( "AddressEntity", "AdventureWorks", "Person", "Address", 8 )
            MyBase.AddElementFieldMapping( "AddressEntity", "AddressId", "AddressID", False, CInt(SqlDbType.Int), 0, 0, 10, True, "SCOPE_IDENTITY()", Nothing, GetType(System.Int32), 0 )
            ... some other fields mapping
        End Sub

They're called when you first access your adapter and for all the entities of your llblgen project. If your config is fine, you should be able to place a break point next to the InitAddressEntityMappings bit and get to it at run time.

Now those funtion make use of the following core method:

        protected void AddElementMapping( string elementName, string catalogName, string schemaName, string targetName, int numberOfFields)
        {
            try
            {
                _elementMappings.Add( elementName, new ElementToTargetMapping( catalogName, schemaName, targetName, numberOfFields ) );
            }
...some unimportant catching
        }

And here's the bit of code that raises your exception:

private ElementToTargetMapping GetElementMappingInfo( string elementName )
        {
            ElementToTargetMapping toReturn = null;
            if( !_elementMappings.TryGetValue( elementName, out toReturn ) )
            {
                throw new ArgumentException( "The element name '" + elementName + "' isn't known in this provider", "elementName" );
            }
            return toReturn;
        }

As you can see, this is quite straight forward and there's not much place for any other reason than not having the right mappings inserted in the first place.

zbussinger
User
Posts: 3
Joined: 29-Aug-2006
# Posted on: 29-Aug-2006 18:28:38   

ok, i think i understand now. It looks like it was a reference problem; but now, with the reference fixed, it appears that something else is wrong. looks like the database name for the generated SQL insert statement is incorrect. Guess i have to go ask my boss about this one, he's the one that generated this code simple_smile

Thanks for the help.

Otis avatar
Otis
LLBLGen Pro Team
Posts: 39927
Joined: 17-Aug-2003
# Posted on: 29-Aug-2006 20:24:45   

Check 'catalog name overwriting' in the manual simple_smile (Application configuration through .config files)

Frans Bouma | Lead developer LLBLGen Pro