I create a model that hasnt any relation to another tables with EF. when I add it in the context and run app for create database i had an Error in Application-start:
One or more validation errors were detected during model generation: System.Data.Edm.EdmEntityType: : EntityType 'UrlHelper' has no key defined. Define the key for this EntityType. System.Data.Edm.EdmEntityType: : EntityType 'RequestContext' has no key defined. Define the key for this EntityType. System.Data.Edm.EdmEntityType: : EntityType 'HttpContextBase' has no key defined. Define the key for this EntityType. System.Data.Edm.EdmEntityType: : EntityType 'Exception' has no key defined. Define the key for this EntityType. System.Data.Edm.EdmEntityType: : EntityType 'Type' has no key defined. Define the key for this EntityType.
Code in my global.asax is like below:
public class MyInitializer
: DropCreateDatabaseIfModelChanges<DBTa>
{
}
protected void Application_Start()
{
//for creating and initializing database
System.Data.Entity.Database.SetInitializer(new MyInitializer());
**DBTa db = new DBTa();**//Error shows here
db.Database.Initialize(true);
//
AreaRegistration.RegisterAllAreas();
RegisterGlobalFilters(GlobalFilters.Filters);
RegisterRoutes(RouteTable.Routes);
}
but when i removed model from app my problem solved, but i need this Model.
please help thanks a lot