Entity Framework Code First - BrokenRule has no key defined

Entity Framework Code First - BrokenRule has no key defined

Old forum URL: forums.lhotka.net/forums/t/12343.aspx


asprog posted on Tuesday, February 04, 2014

Hi,

I'm trying to create my first application with CSLA and Entity Framework using code first.

But when the client tries to load data for the first time after start I get the following exception on the server:

A first chance exception of type 'System.Data.Entity.ModelConfiguration.ModelValidationException' occurred in EntityFramework.dll

Additional information: One or more validation errors were detected during model generation:

Basilisque.Base.ClientBase.Service.Business.BrokenRule: : EntityType 'BrokenRule' has no key defined. Define the key for this EntityType.

BrokenRules: EntityType: EntitySet 'BrokenRules' is based on type 'BrokenRule' that has no keys defined.

While I can read the error and understand that there is no key defined, I don't know how to fix that.

There is no type 'Basilisque.Base.ClientBase.Service.Business.BrokenRule'. There is no type 'BrokenRule'in my solution at all. So I guess CSLA generates that type at runtime?

 

Here is the StackTrace:

   bei System.Data.Entity.Core.Metadata.Edm.EdmModel.Validate()

   bei System.Data.Entity.DbModelBuilder.Build(DbProviderManifest providerManifest, DbProviderInfo providerInfo)

   bei System.Data.Entity.DbModelBuilder.Build(DbConnection providerConnection)

   bei System.Data.Entity.Internal.LazyInternalContext.CreateModel(LazyInternalContext internalContext)

   bei System.Data.Entity.Internal.RetryLazy`2.GetValue(TInput input)

   bei System.Data.Entity.Internal.LazyInternalContext.InitializeContext()

   bei System.Data.Entity.Internal.InternalContext.Initialize()

   bei System.Data.Entity.Internal.InternalContext.GetEntitySetAndBaseTypeForType(Type entityType)

   bei System.Data.Entity.Internal.Linq.InternalSet`1.Initialize()

   bei System.Data.Entity.Internal.Linq.InternalSet`1.get_InternalContext()

   bei System.Data.Entity.Infrastructure.DbQuery`1.System.Linq.IQueryable.get_Provider()

   bei System.Linq.Queryable.Select[TSource,TResult](IQueryable`1 source, Expression`1 selector)

   bei Basilisque.Base.DataAccessBase.Business.BaseDal`4.Fetch() in d:\Develop\ASProg\Basilisque\Main\Source\Base\DataAccessBase\DataAccessBase\Business\BaseDal.cs:Zeile 24.

 

Any suggestions?

Copyright (c) Marimer LLC