1
Vote

Multiple Databases with ActiveRecord

description

Active Record configuration only allows one database configuration. My application allows the user to create multiple databases (based on the same schema) and open them into a tabbed interface. In other words each document is a separate database.
 
My problem is trying to configure Active Record for each document. I can do this at the DataContext level by simply using a different file name in the SqlCE connection string and having each document open it's own DataContext. ActiveRecord can only be configured once.

comments

JeremyS wrote Sep 22, 2010 at 7:56 PM

Thanks for the suggestion, however the ActiveRecord implementation in FluentLinqToSql is purely experimental and at this point is unlikely to see more development now that Microsoft have come out with support for Entity Framework Code Only (which performs a very similar task).

Jeremy

critchie wrote Sep 22, 2010 at 8:42 PM

I agree but the Code First EF stuff will not be production ready for at least another 6-12 months most likely and given the fact that it doesn't even support enum is a problem for me. Your solution is really, really close for the simple 6-7 table application I'm putting together which can't wait until Code First EF is primetime.

I guess I can overlook the enums possibly.

By the way... it appears that when mapping by convention Fluent LinqToSql maps enums to an Association when it should be mapping it to a Column. When using an external mapping source with LinqToSql I use a Column mapping for my enums and they wire right up.
    public CustomerType CustomerType { get; set; }

  <Column Member="CustomerType" DbType="int not null" Name="CustomerType" />

JeremyS wrote Sep 23, 2010 at 7:45 AM

The EF Code First bits are already closer to production ready than FluentLinqToSql's ActiveRecord. I would highly recommend against using this in a production environment.

I'm aware of the enum issue...I never finished implementing the convention mapping rules (in fact, a huge amount is still unfinished). However, at this point I'm not planning to do any further development on FluentLinqToSql, but if you feel like fixing it yourself then I will happily apply any pull requests.

wrote Feb 13, 2013 at 2:55 AM