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