This is a migrated thread and some comments may be shown as answers.

Metadata for Field Cannot Be Initialized.

3 Answers 106 Views
Data Access Free Edition
This is a migrated thread and some comments may be shown as answers.
This question is locked. New answers and comments are not allowed.
EVP
Top achievements
Rank 2
EVP asked on 09 Feb 2015, 10:01 PM
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

3 Answers, 1 is accepted

Sort by
0
Accepted
Boris Georgiev
Telerik team
answered on 12 Feb 2015, 09:09 PM
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.
 
0
EVP
Top achievements
Rank 2
answered on 12 Feb 2015, 09:52 PM
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
0
Boris Georgiev
Telerik team
answered on 13 Feb 2015, 01:58 PM
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.
 
Tags
Data Access Free Edition
Asked by
EVP
Top achievements
Rank 2
Answers by
Boris Georgiev
Telerik team
EVP
Top achievements
Rank 2
Share this question
or