MVC Databasefirst Connection Database

Source: Internet
Author: User

1. Configure the connection string to configure multiple
 
   
  
  1. <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
  
 
  1. <!--现存数据库连接串-->
  2. <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" />
  3. <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


 
   
  
  1. metasearchdbentities1 Dben = new MetaSearchDBEntities1 ();
  2. var a = Dben m_monitorsword tolist






From for notes (Wiz)

MVC Databasefirst Connection Database

Contact Us

The content source of this page is from Internet, which doesn't represent Alibaba Cloud's opinion; products and services mentioned on that page don't have any relationship with Alibaba Cloud. If the content of the page makes you feel confusing, please write us an email, we will handle the problem within 5 days after receiving your email.

If you find any instances of plagiarism from the community, please send an email to: info-contact@alibabacloud.com and provide relevant evidence. A staff member will contact you within 5 working days.

A Free Trial That Lets You Build Big!

Start building with 50+ products and up to 12 months usage for Elastic Compute Service

  • Sales Support

    1 on 1 presale consultation

  • After-Sales Support

    24/7 Technical Support 6 Free Tickets per Quarter Faster Response

  • Alibaba Cloud offers highly flexible support services tailored to meet your exact needs.