Click here to Skip to main content
15,878,814 members
Please Sign up or sign in to vote.
0.00/5 (No votes)
In SQL Server named two Tables like this :
1-FXXL$Purchase Line
2- FXXL$Purchase Header

when i build a Modles then Dbcontext and trying to call those Tables with different form or name because i can't leave space or write '$' it won't call and the value is always null . i tried many forms but it doesn't work so far

i have two Lists of those classes :

What I have tried:

public WebshopDbContext(DbContextOptions<WebshopDbContext> dbContextOptions) : base (dbContextOptions)
       {

       }
       public List<FXXLPurchase_Header> FXXLPurchase_Header { get; set; }
       public List<FXXL_Purchase_Line> FXXLPurchase_Line { get; set; }
Posted
Updated 12-Sep-19 22:53pm

I don't get you...

During the process of creating models, you have to use classes with friendly names:
C#
[Table("FXXL$Purchase Line")]
public class PurchaseLine
{
   //members here
}


Then you have to use the name of class:
C#
public List<PurchaseLine> FXXLPurchaseLine{ get; set; }


See: Code First Data Annotations - EF6 | Microsoft Docs[^]
 
Share this answer
 
Comments
Simon_Whale 13-Sep-19 5:50am    
Exactly what I would of said and have done many times
[no name] 13-Sep-19 6:01am    
did you get the same problem once ? didn't get you very well .
Simon_Whale 13-Sep-19 6:27am    
Yes I have and regularly use where I need to have the class name different to the actual table name. You can also use the [Table] attribute when you need to include schema's in your database design
[no name] 13-Sep-19 6:53am    
Thanks for info Simon. i got you
Maciej Los 13-Sep-19 6:05am    
Thank you, Simon.
 
Share this answer
 
v2
Comments
[no name] 13-Sep-19 6:00am    
thanks for your help .

This content, along with any associated source code and files, is licensed under The Code Project Open License (CPOL)



CodeProject, 20 Bay Street, 11th Floor Toronto, Ontario, Canada M5J 2N8 +1 (416) 849-8900