2

I working in Asp.net with entity framework in vs 2010 with oracle database. I provide connection string from code for entity frame work datacontext. Here is my code:

public static string getConStrSQL()
    {

        //string connectionString = new System.Data.EntityClient.EntityConnectionStringBuilder
        string connectionString = new System.Data.EntityClient.EntityConnectionStringBuilder
        {
            Metadata = "res://*",
            Provider = "Oracle.ManagedDataAccess.Client",
            //Provider = "Oracle.DataAccess.Client",
            ProviderConnectionString = new System.Data.SqlClient.SqlConnectionStringBuilder
            {
                //InitialCatalog = "ORCL",
                DataSource = "MONOJ-PC:1521/ORCL",
                //IntegratedSecurity = false,
                UserID = "C##MONOJ",                 // User ID such as "sa"
                Password = "Thanks123",               // hide the password
            }.ConnectionString
        }.ConnectionString;

        return connectionString;
    }

    public List<CUSTOMER> GetCustomerList()
    {

        using (Entities db = new Entities())
        {
            db.Connection.ConnectionString = getConStrSQL();
            db.Connection.Open();

            var data = from p in db.CUSTOMERs
                       select p;

            db.Connection.Close();

            return data.ToList();
        }
    }

But when i run the Code i get Following errors:

Schema specified is not valid. Errors: error 0194: All artifacts loaded into an ItemCollection must have the same version. Multiple versions were encountered. DAL.DBModel.ssdl(2,46) : error 0172: All SSDL artifacts must target the same provider. The Provider 'Oracle.DataAccess.Client' is different from 'Oracle.DataAccess.Client' that was encountered earlier. DAL.DBModel.ssdl(2,89) : error 0169: All SSDL artifacts must target the same provider. The ProviderManifestToken '12.1' is different from '9.2' that was encountered earlier. Oracle.ManagedDataAccess.src.EntityFramework.Resources.EFOracleStoreSchemaDefinition.ssdl(3,4) : error 0019: The EntityContainer name must be unique. An EntityContainer with the name 'Schema' is already defined. Oracle.ManagedDataAccess.src.EntityFramework.Resources.EFOracleStoreSchemaDefinition.ssdl(834,4) : error 0019: Each type name in a schema must be unique. Type name 'Oracle.Table' was already defined. Oracle.ManagedDataAccess.src.EntityFramework.Resources.EFOracleStoreSchemaDefinition.ssdl(844,4) : error 0019: Each type name in a schema must be unique. Type name 'Oracle.TableColumn' was already defined. Oracle.ManagedDataAccess.src.EntityFramework.Resources.EFOracleStoreSchemaDefinition.ssdl(870,4) : error 0019: Each type name in a schema must be unique. Type name 'Oracle.View' was already defined. Oracle.ManagedDataAccess.src.EntityFramework.Resources.EFOracleStoreSchemaDefinition.ssdl(882,4) : error 0019: Each type name in a schema must be unique. Type name 'Oracle.ViewColumn' was already defined. Oracle.ManagedDataAccess.src.EntityFramework.Resources.EFOracleStoreSchemaDefinition.ssdl(908,4) : error 0019: Each type name in a schema must be unique. Type name 'Oracle.Function' was already defined. Oracle.ManagedDataAccess.src.EntityFramework.Resources.EFOracleStoreSchemaDefinition.ssdl(933,4) : error 0019: Each type name in a schema must be unique. Type name 'Oracle.Procedure' was already defined. Oracle.ManagedDataAccess.src.EntityFramework.Resources.EFOracleStoreSchemaDefinition.ssdl(943,4) : error 0019: Each type name in a schema must be unique. Type name 'Oracle.Parameter' was already defined. Oracle.ManagedDataAccess.src.EntityFramework.Resources.EFOracleStoreSchemaDefinition.ssdl(967,4) : error 0019: Each type name in a schema must be unique. Type name 'Oracle.Constraint' was already defined. Oracle.ManagedDataAccess.src.EntityFramework.Resources.EFOracleStoreSchemaDefinition.ssdl(979,4) : error 0019: Each type name in a schema must be unique. Type name 'Oracle.CheckConstraint' was already defined. Oracle.ManagedDataAccess.src.EntityFramework.Resources.EFOracleStoreSchemaDefinition.ssdl(987,4) : error 0019: Each type name in a schema must be unique. Type name 'Oracle.ConstraintColumn' was already defined. Oracle.ManagedDataAccess.src.EntityFramework.Resources.EFOracleStoreSchemaDefinition.ssdl(996,4) : error 0019: Each type name in a schema must be unique. Type name 'Oracle.ForeignKeyConstraint' was already defined. Oracle.ManagedDataAccess.src.EntityFramework.Resources.EFOracleStoreSchemaDefinition.ssdl(1005,4) : error 0019: Each type name in a schema must be unique. Type name 'Oracle.ForeignKey' was already defined. Oracle.ManagedDataAccess.src.EntityFramework.Resources.EFOracleStoreSchemaDefinition.ssdl(1016,4) : error 0019: Each type name in a schema must be unique. Type name 'Oracle.ViewConstraint' was already defined. Oracle.ManagedDataAccess.src.EntityFramework.Resources.EFOracleStoreSchemaDefinition.ssdl(1031,4) : error 0019: Each type name in a schema must be unique. Type name 'Oracle.TableTableConstraint' was already defined. Oracle.ManagedDataAccess.src.EntityFramework.Resources.EFOracleStoreSchemaDefinition.ssdl(1044,4) : error 0019: Each type name in a schema must be unique. Type name 'Oracle.ConstraintConstraintColumn' was already defined. Oracle.ManagedDataAccess.src.EntityFramework.Resources.EFOracleStoreSchemaDefinition.ssdl(1057,4) : error 0019: Each type name in a schema must be unique. Type name 'Oracle.ConstraintForeignKey' was already defined. Oracle.ManagedDataAccess.src.EntityFramework.Resources.EFOracleStoreSchemaDefinition.ssdl(1070,4) : error 0019: Each type name in a schema must be unique. Type name 'Oracle.FromForeignKeyColumn' was already defined. Oracle.ManagedDataAccess.src.EntityFramework.Resources.EFOracleStoreSchemaDefinition.ssdl(1083,4) : error 0019: Each type name in a schema must be unique. Type name 'Oracle.ToForeignKeyColumn' was already defined. Oracle.ManagedDataAccess.src.EntityFramework.Resources.EFOracleStoreSchemaDefinition.ssdl(1096,4) : error 0019: Each type name in a schema must be unique. Type name 'Oracle.TableTableColumn' was already defined. Oracle.ManagedDataAccess.src.EntityFramework.Resources.EFOracleStoreSchemaDefinition.ssdl(1109,4) : error 0019: Each type name in a schema must be unique. Type name 'Oracle.ViewViewColumn' was already defined. Oracle.ManagedDataAccess.src.EntityFramework.Resources.EFOracleStoreSchemaDefinition.ssdl(1122,4) : error 0019: Each type name in a schema must be unique. Type name 'Oracle.FunctionFunctionParameter' was already defined. Oracle.ManagedDataAccess.src.EntityFramework.Resources.EFOracleStoreSchemaDefinition.ssdl(1135,4) : error 0019: Each type name in a schema must be unique. Type name 'Oracle.ProcedureProcedureParameter' was already defined. Oracle.ManagedDataAccess.src.EntityFramework.Resources.EFOracleStoreSchemaDefinition.ssdl(1148,4) : error 0019: Each type name in a schema must be unique. Type name 'Oracle.ViewViewConstraint' was already defined. Oracle.ManagedDataAccess.src.EntityFramework.Resources.EFOracleStoreSchemaDefinition.ssdl(1161,4) : error 0019: Each type name in a schema must be unique. Type name 'Oracle.ViewConstraintConstraintColumn' was already defined. Oracle.ManagedDataAccess.src.EntityFramework.Resources.EFOracleStoreSchemaDefinition.ssdl(1174,4) : error 0019: Each type name in a schema must be unique. Type name 'Oracle.ViewConstraintForeignKey' was already defined. Oracle.ManagedDataAccess.src.EntityFramework.Resources.EFOracleStoreSchemaDefinition.ssdl(1187,4) : error 0019: Each type name in a schema must be unique. Type name 'Oracle.FromForeignKeyViewColumn' was already defined. Oracle.ManagedDataAccess.src.EntityFramework.Resources.EFOracleStoreSchemaDefinition.ssdl(1200,4) : error 0019: Each type name in a schema must be unique. Type name 'Oracle.ToForeignKeyViewColumn' was already defined.

I googled but can not get any answer. Please, Help me. It's argent.

2
  • How many .edmx files do you have in your project? Commented Jan 23, 2015 at 6:40
  • Thank you for reply, one .edmx file in my project.... Commented Jan 23, 2015 at 13:24

2 Answers 2

2

Check your project references -- you may be including a project that "brings along" it's own database/schema. As in:

  • Project A --> has EF version X, database project_a.edmx
  • Project B --> references 'Project A', has EF version Y, database project_b.edmx

where versions X and Y may be different.

This may be due to different connection strings generated depending on the .NET/EF versions -- see more http://weblogs.asp.net/kencox/schema-specified-is-not-valid-error-on-upgrading-to-asp-net-4

Sign up to request clarification or add additional context in comments.

Comments

1

I know that this answare it's late, but I hope it server future references.

I was having the same problem, and I found out that the issue was in specify the metadata correctly:

string connectionString = new System.Data.EntityClient.EntityConnectionStringBuilder
{
    Metadata = "res://*/Models.ModelKDM.csdl|res://*/Models.ModelKDM.ssdl|res://*/Models.ModelKDM.msl",
    Provider = "Oracle.DataAccess.Client",
    ProviderConnectionString = new System.Data.SqlClient.SqlConnectionStringBuilder
    {
        DataSource = server,
        UserID = user,
        Password = pass,
    }.ConnectionString
}.ConnectionString;
return connectionString;

Comments

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Start asking to get answers

Find the answer to your question by asking.

Ask question

Explore related questions

See similar questions with these tags.