Code First Entity Framework - change connection string

前端 未结 1 539
醉话见心
醉话见心 2021-01-08 00:55

How do I change the connection string in a code first entity framework/MVC application? I\'m trying to transfer it to a live site, but it overlooks web config values and st

相关标签:
1条回答
  • 2021-01-08 01:03

    The connection string or its name can be passed to constructor of DbContext. If you are using default constructor it searches for the connection string with the same name as the name of your derived context class and if it doesn't find it, it uses this one:

    Data Source=.\SQLEXPRESS; Integrated Security=True; MultipleActiveResultSets=True
    

    With database name same like your context class.

    0 讨论(0)
提交回复
热议问题