Method to Create an Entity Framework Object Context

Posted by Kubi on Stack Overflow See other posts from Stack Overflow or by Kubi
Published on 2010-05-10T06:17:47Z Indexed on 2010/05/10 6:24 UTC
Read the original article Hit count: 430

Filed under:
    public RBSEntities GetContext()
    {
        SqlConnectionStringBuilder sqlBuilder = new SqlConnectionStringBuilder();
        sqlBuilder.DataSource = "a-pc";
        sqlBuilder.InitialCatalog = "ABS";
        sqlBuilder.IntegratedSecurity = true;
        string providerString = sqlBuilder.ToString();
        EntityConnectionStringBuilder entityBuilder = new EntityConnectionStringBuilder();
        entityBuilder.Provider = "System.Data.SqlClient";
        entityBuilder.ProviderConnectionString = providerString;
        entityBuilder.Metadata = @"res://*/RBSModel.csdl|
                        res://*/RBSModel.ssdl|
                        res://*/RBSModel.msl";

        RBSEntities entities = new RBSEntities(entityBuilder.ToString());
        return entities;
    }

Something wrong with the Metadata. Anybody having an idea about how to fix this ?

© Stack Overflow or respective owner

Related posts about entity-framework