none
Entity framework connection string reference from another project RRS feed

  • Question

  • I have a solution consisting of 4 projects. MVC, WCF, Business LYR, DataAcess. I am using entity framework for database transaction. My requirement is that i want to fetch the entity connectionstring only from MVC webconfig without refering in APP.cofig of acess layer. Is it possible in this scenario?

    While I tried the following code I got an error.

     this.ConnectionString="data source=cmh-sosql;initial catalog=Student;integrated security=True;MultipleActiveResultSets=True;App=EntityFramework";
    
                System.Data.SqlClient.SqlConnectionStringBuilder scsb = new System.Data.SqlClient.SqlConnectionStringBuilder(this.ConnectionString);
    
    EntityConnectionStringBuilder ecb = new EntityConnectionStringBuilder();
    ecb.Metadata = "res://*/schoolModel.csdl|res://*/schoolModel.ssdl|res://*/schoolModel.msl";
    ecb.Provider = "System.Data.SqlClient";
    ecb.ProviderConnectionString = scsb.ConnectionString;
    
    using (SchoolDB schoolDB = new SchoolDB(ecb.ConnectionString))

    Error: The entity type student is not part of the model for the current context.

    Saturday, December 15, 2012 11:42 AM

Answers

  • Hi Felix,

    Welcome to the MSDN forum.

    Please try to use this to check if the error occurs or not:

    ecb.Metadata = @"res://*/schoolModel.csdl|res://*/schoolModel.ssdl|res://*/schoolModel.msl";

    Have a nice day.


    Alexander Sun [MSFT]
    MSDN Community Support | Feedback to us
    Develop and promote your apps in Windows Store
    Please remember to mark the replies as answers if they help and unmark them if they provide no help.

    • Marked as answer by Alexander Sun Wednesday, December 26, 2012 2:42 AM
    Monday, December 17, 2012 8:48 AM