ASP. NET Mvc:ef does not create a database table

Source: Internet
Author: User

When setting the connection string, the value of the Name property should be equal to the class name of the EF database class created

Like what:

Using system;using system.collections.generic;using system.linq;using system.web;using System.Data.Entity;using MVC_ Example. Models;namespace Mvc_example. dataaccesslayer{public    class Cnn:dbcontext    {        private dbset<user> _users;        Public dbset<user> Users        {            get            {                return _users;            }            Set            {                _users = value;            }        }        protected override void Onmodelcreating (Dbmodelbuilder modelBuilder)        {            modelbuilder.entity<user> () . ToTable ("TUser");            Base. Onmodelcreating (ModelBuilder);}}}    

Where the class named CNN is defined, the ConnectionString in Web. config

should be:

<connectionStrings>    <add connectionstring= "Data source=.;i Nitial catalog=saleserpdb;integrated security=true; "Name=" Cnn "providername=" System.Data.SqlClient "/>  < /connectionstrings>

ASP. NET Mvc:ef does not create a database table

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.