I'm working on an ASP MVC project.
Here are the steps I followed :
- I added entity framework in my project references
I connected to my SQL SERVER database and then copied the associated connection string in
Web.config
using this answer. The connection is successfulI created manually my own DbContex class. Below is its code :
public class MyConxtext : DbContext { public MyConxtext() : base("name = MyConnString"){} public DbSet<user> user { get; set; } }
Now user here not only is the name of my table user
in SQL server but also is the name of my model user
in my ASP MVC.
My problem is that :
- when I wanted to persist (several item in a session) via MyContext.SaveChanges()
, it has created another table in my database named users
... Notice the plural here users
... So instead of working on the table user
, it created another table called users
and persited data on that table.
My context also is not able to read data from the user
table. BUT as I said it processes everything is the schema of the connection string
How can I solve that problem ?
Not only that it has also created another table in my schema called MigrationHistory
which contain data about my project...