1. Configure the connection string to configure multiple
<add name="MetaSearchConnectionString" connectionString="Data Source=(local);Initial Catalog=MetaSearchDB;Persist Security Info=True;User ID=sa;Password=12345012345;Pooling=true;Min Pool Size=20;Max Pool Size=50000;" providerName="System.Data.SqlClient" />
2. Add a data Model
Select the connection string set in Webconfig, and the Entitie name below is the entity name to use
3.the connection string in the database becomes the following two parts
<!--现存数据库连接串-->
<add name="MetaSearchConnectionString" connectionString="Data Source=(local);Initial Catalog=MetaSearchDB;Persist Security Info=True;User ID=sa;Password=12345012345;Pooling=true;Min Pool Size=20;Max Pool Size=50000;" providerName="System.Data.SqlClient" />
<add name="MetaSearchDBEntities1" connectionString="metadata=res://*/dbentities.db1.csdl|res://*/dbentities.db1.ssdl|res://*/dbentities.db1.msl;provider= System.data.sqlclient;provider Connection string= "Data Source=(local); Initial Catalog=metasearchdb;persist Security Info=True;user ID=Sa;password=12345012345;pooling=true;min Pool size=20;max Pool size=50000;multipleactiveresultsets=true;application name=entityframework "" ProviderName="System.Data.EntityClient" />
4. database table diagram for production
The model of the production entity class and table is as follows
5. Using the same as Codefirst, the method of use
metasearchdbentities1 Dben = new MetaSearchDBEntities1 ();
var a = Dben m_monitorsword tolist
From for notes (Wiz)
MVC Databasefirst Connection Database