This question is locked. New answers and comments are not allowed.
Alright, I've been pulling my hair out over this for nearly 3 days, and I'm about to scrap everything and abandon OpenAccess unless someone can point me in the right direction.
I've got an OpenAccess library that is connected to a SQL Azure database, and the compiled assembly is referenced in an MVC4 website. Pretty straightforward. But regardless how I create the OA entities, I always end up with this error:
Yes, that has been automatically added to my project. I tried every configuration/tweak from this thread:
http://www.sitefinity.com/developer-network/forums/developing-with-sitefinity-/no-metadata-has-been-registered-for-class-locationsmodule-model-locationitem
I've gone about as basic as I can get and still receive the error. Here's my dummy model:
My DataContext:
And lastly, my MetadataSource:
All that compiles fine, but runtime throws the error. I'm developing locally on the Azure SDK, so this is all running on the Azure Fabric Compute/Storage emulators, but the Azure DB connection is pointed to a live Azure DB.
Can anybody help? God help me, I don't want to revert to Entity Framework, but I'm running out of time an options.
I've got an OpenAccess library that is connected to a SQL Azure database, and the compiled assembly is referenced in an MVC4 website. Pretty straightforward. But regardless how I create the OA entities, I always end up with this error:
No metadata has been registered for class 'DummyProject.Data.Models.DummyModel, DummyProject.Data, Version=1.0.0.0, Culture=neutral, PublicKeyToken=null'. (This usually indicates, that either this class is not declared persistent or it is declared persistent but not enhanced.)
I've tried creating the classes several ways:
- OpenAccess Class Library, XML Mapping
- OpenAccess Class Library, Attribute Mapping
- OpenAccess Class Library, Fluent Mapping
- OpenAccess Fluent Library (Code Only)
Using the first 3 methods, I generated classes from an existing Azure DB schema. When I wasted enough time, I ignored the database and attempted the 4th method as code-first. They all eventually failed with this error. For each attempt, I completely deleted the old class library and created a new project, to avoid any "leftovers" causing problems.
I've tried just about every solution I could find, but nothing has worked:
<Import Condition="Exists('$(MSBuildExtensionsPath)\OpenAccess.targets')" Project="$(MSBuildExtensionsPath)\OpenAccess.targets" />Yes, that has been automatically added to my project. I tried every configuration/tweak from this thread:
http://www.sitefinity.com/developer-network/forums/developing-with-sitefinity-/no-metadata-has-been-registered-for-class-locationsmodule-model-locationitem
I've gone about as basic as I can get and still receive the error. Here's my dummy model:
public class DummyModel{ public int DummyId { get; set; } public string DummyText { get; set; }}My DataContext:
public partial class DummyDataContext : OpenAccessContext { static MetadataContainer metadataContainer = new DummyMetadataSource().GetModel(); static BackendConfiguration backendConfiguration = new BackendConfiguration() { Backend = "Azure", ProviderName = "System.Data.SqlClient" }; private const string DbConnection = "DefaultConnection"; public DummyDataContext () : base(DbConnection, backendConfiguration, metadataContainer) { } public IQueryable<DummyModel> Dummies { get { return this.GetAll<DummyModel>(); } } public void UpdateSchema() { var handler = this.GetSchemaHandler(); string script = null; try { script = handler.CreateUpdateDDLScript(null); } catch { bool throwException = false; try { handler.CreateDatabase(); script = handler.CreateDDLScript(); } catch { throwException = true; } if (throwException) throw; } if (string.IsNullOrEmpty(script) == false) { handler.ExecuteDDLScript(script); } } }And lastly, my MetadataSource:
public class DummyDataMetadataSource : FluentMetadataSource { protected override IList<MappingConfiguration> PrepareMapping() { List<MappingConfiguration> configurations = new List<MappingConfiguration>(); MappingConfiguration<DummyModel> dummyConfiguration = new MappingConfiguration<DummyModel>(); dummyConfiguration .MapType().ToTable("Dummies"); dummyConfiguration .HasProperty(x => x.DummyId).IsIdentity(); configurations.Add(dummyConfiguration ); return configurations; } }Can anybody help? God help me, I don't want to revert to Entity Framework, but I'm running out of time an options.