Single Connection String with Multiple Entity Framework Models?

后端 未结 3 2191
孤街浪徒
孤街浪徒 2021-02-08 18:33

At work we currently have a very large web application with a connection to a massive database. We have been using Entity Framework for a while now and to make things easier we

3条回答
  •  粉色の甜心
    2021-02-08 19:10

    I had the same problem. I have solved it by following way:

    I have created two edmx file, but while creating second edmx file, i ignored the connection string to be save in config file. This way my config file will hold only one Connection string. Then i modified following lines in my connection string:

    
    

    Just replace "res://model1.csdl" with "res://*/" and it works like a charm.

    You can specify this connection name in constructor of your dbcontext class like:

    public MyDbContext() : base("name=NameOfYourConnectionString") //  Name of your connection string
    { }
    

    Note: I am using Entity Framework 5.0.

提交回复
热议问题