Yes it is actually. You can provide a mapping file when you instantiante a DataContext like so:
var dataContext = new DataContext("connectionstring", entity.map);
This file can be autogenerated with SqlMetal.exe:
sqlmetal /server:servername /database:databasename /context:nameofdatacontext /Map:Entity.Map /code:Entity.code
So if you stick with the convention to name the properties the same in db and i enties, you will be up an running.
Furthermore you can use T4 templates to generate your datacontext, by also generating the dbml file.
I have created a .bat file, that i execute from solution explorer with powershell.exe, that
- runs sqlmetal.exe with map parameter
- runs sqlmetal.exe with dbml parameter
- and runs TextTransform.exe on my T4 template that generates my datacontex.
But you should probably use EntitySet<T>
and EntityRef<T>
in your entity if you don't want lack normal functionality like lazyload. This obviously means that you will not have clean POCOs, but if you can live with that, its a fairly small tradeoff.