Problem with implementation

Nov 20, 2011 at 10:01 AM

Hi All,

This solution is something I could greatly use (if I could get it to work) since I generate a lot of data from reading my DB and analyzing it using EF.

I have a DB table "Prefs" which has 100 items.

I created an EF connection using VS2010 wizard and all works well.

I have created a DB table "1_Prefs" and used the model atapter with TablePreffixModelAdapter("1_") command in the ObjectContext constructor.

If I try to create the ObjectContext with the new adopting classes, there is an exception thrown: - using(var ctx = new MyContext())

{System.Data.MappingException: Schema specified is not valid. Errors:
(0,0) : error 2007: The Table '1_SystemPreferences' specified as part of this MSL does not exist in MetadataWorkspace.
(0,0) : error 2063: At least one property must be mapped in the set mapping for 'SystemPreferences'.
   at System.Data.Mapping.StorageMappingItemCollection.Init(EdmItemCollection edmCollection, StoreItemCollection storeCollection, IEnumerable`1 xmlReaders, List`1 filePaths, Boolean throwOnError)
   at System.Data.Mapping.StorageMappingItemCollection..ctor(EdmItemCollection edmCollection, StoreItemCollection storeCollection, IEnumerable`1 xmlReaders)
   at BrandonHaynes.ModelAdapter.EntityFramework.ConnectionAdapter.CreateWorkspace(XmlReader conceptualReader, XmlReader storageReader, XmlReader mappingReader) in C:\ConsoleApplication3\Model Adapter\Connection Adapters\ConnectionAdapter.cs:line 160
   at BrandonHaynes.ModelAdapter.EntityFramework.ConnectionAdapter.AdaptWorkspace(EntityConnectionStringBuilder connectionData) in C:\ConsoleApplication3\Model Adapter\Connection Adapters\ConnectionAdapter.cs:line 100
   at BrandonHaynes.ModelAdapter.EntityFramework.ConnectionAdapter.AdaptConnection(String connectionString) in C:\ConsoleApplication3\Model Adapter\Connection Adapters\ConnectionAdapter.cs:line 77
   at BrandonHaynes.ModelAdapter.EntityFramework.AdaptingObjectContext..ctor(String connectionString, String defaultContainerName, IConnectionAdapter adapter) in C:\ConsoleApplication3\Model Adapter\Object Contexts\AdaptingObjectContext.cs:line 19
   at ConsoleApplication3.CSTEntities..ctor(String connectionString) in C:\ConsoleApplication3\CstModel.Designer.cs:line 47
   at ConsoleApplication3.Program.Main(String[] args) in C:\ConsoleApplication3\Program.cs:line 16}


the exception is thrown in the following line in the ConnectionAdapter class:

var mappingCollection = new StorageMappingItemCollection(conceptualCollection, storageCollection,

any help will be appreciated...