Metadata for Field Cannot Be Initialized.

4 posts, 1 answers
  1. EVP
    EVP avatar
    8 posts
    Member since:
    Jul 2013

    Posted 09 Feb 2015 Link to this post

    I'm experiencing an issue when I changed a field type from within the model editor. After changing the type for the field, I assumed I could push the update to the database (MSSQL) and it would update the type, however I received an error. No sweat. I expected as much. So I went into the database and manually updated the field type, to match, still no luck though. Now I have a build error:

    Error   7  
    The metadata for field '_electric' of class 'Wing_Fest_Data_Model.Restaurant' cannot be initialized: Type converter initialization failed. The converter with name 'OpenAccessRuntime.Data.VariableLengthAnsiStringConverter' does not convert from CLR type 'System.Boolean' to SQL type 'varchar'.
    Parameter name: converterName
    Actual value was OpenAccessRuntime.Data.VariableLengthAnsiStringConverter.  0   0   Wing Fest Data Model


    There are several of these when trying to build. 

    Next, I tried to create a new database, using the same EntitiesModel rlinq file, but the same issue keeps occurring. The database itself has the correct mappings, matching the model in the designer. I'm guessing the metadata for the rlinq file isn't updatin/matching up.

    So, my questions are:

    1.) How can I solve this current issue (e.g. update the metadata of the file)
    2.) Going forward, is there a 'better' (I know, a loose term) approach to changing the type of a field (e.g. from a string to a boolean)? For a development database.

    Running Latest Update of DataAccess, on VS2013 Ultimate. MSSQL Server 2014 backend.

    thanks much!

    Eric

  2. Answer
    Boris Georgiev
    Admin
    Boris Georgiev avatar
    190 posts

    Posted 12 Feb 2015 Link to this post

    Hi Eric,

    If I understood correctly you have updated the SQL type of the column mapped to a property using the Table Editor(or through the Model Schema Explorer - Properties window). So after this change, the type of the column mapped to the property in the metadata will be changed so if you try to update the database, it will try to update the type of the column, but then the type of the property in the domain class is still boolean and this is why it will throws an exception in the Update Database from Model wizard. Therefore if you want to change a column type you should change the type of the column as well as you should also change the type of the property which is mapped to the column. You can update the property type through the VIsual Designer or Model Object Explorer - Properties window.

    I hope that helps.

    Regards,
    Boris Georgiev
    Telerik
     
    OpenAccess ORM is now Telerik Data Access. For more information on the new names, please, check out the Telerik Product Map.
     
  3. DevCraft banner
  4. EVP
    EVP avatar
    8 posts
    Member since:
    Jul 2013

    Posted 12 Feb 2015 in reply to Boris Georgiev Link to this post

    Hi Boris,

    That fixed it, thanks! I suppose I should not have assumed that by updating a field in the model editor that it would copy over to the table editor as well. Good to know.

    Out of curiosity, is there a reason DataAccess doesn't copy it over automatically, or make an attempt to? Perhaps a feature for a later release, unless you guys have good reasons not to?

    thanks again,

    Eric
  5. Boris Georgiev
    Admin
    Boris Georgiev avatar
    190 posts

    Posted 13 Feb 2015 Link to this post

    Hi Eric,

    Telerik Data Access automatically modifies the type of the column when you change the type of the property only if you have default mapping. If you change something in the mapping and the mapping is no longer recognized as default one any change to the type of a property should be manually done to the corresponding column. If you are using custom mapping Telerik Data Access avoids making automatic changes in the background without the knowledge of the user.

    I hope this clarifies the behavior of Telerik Data Access in this case.

    Regards,
    Boris Georgiev
    Telerik
     
    OpenAccess ORM is now Telerik Data Access. For more information on the new names, please, check out the Telerik Product Map.
     
Back to Top