Entity Framework - redundant connection string

后端 未结 4 1725
眼角桃花
眼角桃花 2021-02-08 18:57

I\'m using Entity Framework 4 in my project. The Framework has created its own connection string, so my web.config connectionStrings section file looks following:

4条回答
  •  花落未央
    2021-02-08 19:53

    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.

提交回复
热议问题