Code First on designer

3 posts, 0 answers
  1. rd
    rd avatar
    20 posts
    Member since:
    Jun 2007

    Posted 22 May 2012 Link to this post

    Hello, when using code first the following is generated:

    .IsNotNullable().HasColumnType("varchar").HasLength(100)


    The problem is that using like this I cannot use the model with an Oracle DB.
    Any option in the designer so it don't generate VARCHAR ?
  2. rd
    rd avatar
    20 posts
    Member since:
    Jun 2007

    Posted 23 May 2012 Link to this post

    I've tried to remove the HasColumnType("varchar")

    but got:

    The incoming tabular data stream (TDS) remote procedure call (RPC) protocol stream is incorrect. Parameter 13 ("@p9"): Data type 0xE7 has an invalid data length or metadata length.

    Description: An unhandled exception occurred during the execution of the current web request. Please review the stack trace for more information about the error and where it originated in the code.

    Exception Details: Telerik.OpenAccess.RT.sql.SQLException: The incoming tabular data stream (TDS) remote procedure call (RPC) protocol stream is incorrect. Parameter 13 ("@p9"): Data type 0xE7 has an invalid data length or metadata length.
  3. DevCraft banner
  4. Jan Blessenohl
    Admin
    Jan Blessenohl avatar
    707 posts

    Posted 25 May 2012 Link to this post

    Hi,

    Today I can only provide you a workaround. You can manipulate the metadata before you open the database the first time. You can use the default mapping for oracle or replace the sql types with explicit values. To use our default mapping you can create a partial class to your generated context class and override the OnDatabaseOpen method like this:

    public partial class NorthwindModel
    {
        protected override void OnDatabaseOpen(BackendConfiguration backendConfiguration, MetadataContainer metadataContainer)
        {
            // oracle
            if (connectionString.ToLowerInvariant().Contains("oracle")) // derive the oracle setting from something like the connection string!
            {
                foreach (var c in metadataContainer.Tables.SelectMany(x => x.Columns))
                    c.SqlType = null;
                foreach (var i in metadataContainer.Indexes)
                    i.Name = null;
            }
            base.OnDatabaseOpen(backendConfiguration, metadataContainer);
        }



    All the best,
    Jan Blessenohl
    the Telerik team
    Follow @OpenAccessORM Twitter channel to be the first one to get the latest updates on new releases, tips and tricks and sneak peeks at our product labs!
Back to Top