locked
table connection with entity frame work RRS feed

  • Question

  • User-1355965324 posted

    I am using the  entityframe frame work for the new projects . I have a model class called  Employee.cs

    Employee.cs  model
     public class EmployeeModel
        {
    
    
            public int EmployeeID { get; set; }
            [Required]
            [Range(1, Int32.MaxValue, ErrorMessage = "Select Department")]
            public int DepartmentID { get; set; }
            [Required (ErrorMessage ="Select Depot")]
            [Range(1, Int32.MaxValue, ErrorMessage = "Select Depot")]
    }
    
    I have assigned the model with Dbset
    
    public DbSet<EmployeeModel> tblEmployee { get; set; }
    
    
    

    Now how can I give the link or how to connect tblEmployee with physical table without migration to the entityframe work core. I want to give the link Employee model class to the connected database table called Employee.

    Can I give the  data annotation [Table("tblEmployee")], is enough to get the link with physical table. Please can you advise me ?. I would like to add some existing table  to the db context without loosing the data from the table. I have already created the model class and I have added the  model to the dbContext.  Then how  can I update the db context with sqlserver table without loosing  the data

    With Thanks

    Pol



    Wednesday, October 23, 2019 7:57 AM

Answers