How to specify database name in Code First?

后端 未结 7 1350
广开言路
广开言路 2020-12-13 06:00

How do I tell EF what to name the database and where to put it?

If there is no connection string in the Web.Config, it tries to put it in the local SQLEXPRESS Server

7条回答
  •  孤街浪徒
    2020-12-13 06:20

    If you point your connection-string at an existing database then EF “code first” will not try and create one automatically.

    EF “code first” uses a convention where context classes by default look for a connection-string that has the same name as the context class.

    Using ef code first with an existing database

提交回复
热议问题