Using EntityFramework with datatables editor
Using EntityFramework with datatables editor
adam.leinen@fblfinancial.com
Posts: 4Questions: 2Answers: 0
in General
We are starting to use editor to access our database however we currently use EF and our existing models variable names do not match the database names. Can Editor use the EF data annotations to get the column names instead of using the variable names? If it can't are you looking at doing this for a future release? We are trying to avoid renaming all of our variables.
Answers
Hi Adam,
Thanks for your question. At this time, I'm afraid to say that no, we aren't looking to do a complete EF integration for Editor. I did look at it originally, but decided that the ADO.NET data connection was going to be more flexible rather than being bound to just EF.
That said, are you able to use reflection or something other method to read the data annotations (probably of your EF models)? If so, that it would be entirely possible to set up an Editor instance based on that. Are you able to show me one of your EF models please?
Thanks,
Allan
Here is a sample of one of our models. As you can see the Column annotation is our column name which is currently different than the variable name (Ex: commentType). I am able to read the annotations but how would I pass that into Editor?
I read right over the section in your getting started page about Procedural style. I was able to use reflection to read the data annotation from my EF model. Let me know if you have any suggestions how to make it better. Also just a note I used Editor 1.9.6 from nuget and had what seems to be the same issue you've had with nuget in the past. I swapped it out with the DLL from the trial and it got past the error.
Hi Adam,
That looks superb - many thanks for sharing that solution! I think it looks great. The only limitation is that you need another attribute for each validation type, but that might be acceptable, and if we build something like this into the library it would be something we deal with anyway.
Darn - thanks for letting me know about that. I thought I'd finally got it fixed!
Regards,
Allan
I would also appreciate a full entity framework example. I'm making it work but a full integration would be nice.