New Posts New Posts RSS Feed: Error in model generation (code first)
  FAQ FAQ  Forum Search   Calendar   Register Register  Login Login

Error in model generation (code first)

 Post Reply Post Reply Page  <12
Author
Walid View Drop Down
Senior Member
Senior Member
Avatar

Joined: 14-Nov-2010
Posts: 161
Post Options Post Options   Quote Walid Quote  Post ReplyReply Direct Link To This Post Topic: Error in model generation (code first)
    Posted: 24-Sep-2012 at 3:30am
Originally posted by Walid

 
When I try to build I get this error when it was working in the previous with the 6.1.8.

Erreur 1 CodeFirst entities were found in this assembly, but an EntityManager or DbContext was not.  You must define a container for these entities in this assembly. xxx.Common.Domain


This assembly doesn't contains any entitymanager or DBContext because it hosts the base class (all abstract) for all the others domains assemblies.

Is it now mandatory to create a DBContext or entitymanager in any assembly hosting a code first class even if all are abstract  ? 
I created an internal empty entityManager to be able to continue the migration but I feel I shouldn't have to.


Like for the global.asax, the server package created a Devforce.cf file that I didn't notice before.

Removing this file fixed it.

Back to Top
mgood View Drop Down
IdeaBlade
IdeaBlade
Avatar

Joined: 18-Nov-2010
Location: Emeryville, CA
Posts: 583
Post Options Post Options   Quote mgood Quote  Post ReplyReply Direct Link To This Post Posted: 24-Sep-2012 at 3:27am
Walid,
Did you completely uninstall DF 2010? Code-First builds currently do not work with DF 2010 and DF 2012 installed side-by-side.
Back to Top
Walid View Drop Down
Senior Member
Senior Member
Avatar

Joined: 14-Nov-2010
Posts: 161
Post Options Post Options   Quote Walid Quote  Post ReplyReply Direct Link To This Post Posted: 24-Sep-2012 at 2:56am
Another error which doesn't exist in 6.1.8 :


Tâche "EntityModelMetadataDeploy"
  In EntityModelMetadataDeploy.  Parms:  Assembly='C:\Dev\Dev\MigrationDFandCocktail2012\Company\Domains\Management\Company.Management.Domain\bin\Debug\Company.Management.Domain.dll', TargetFolder='C:\Dev\Dev\MigrationDFandCocktail2012\Company\Domains\Management\Company.Management.Domain'
  IdeaBlade.VisualStudio.Build.Tasks, Version=7.0.0.0, Culture=neutral, PublicKeyToken=287b5094865421c0
  Trying model metadata discovery for C:\Dev\Dev\MigrationDFandCocktail2012\Company\Domains\Management\Company.Management.Domain\bin\Debug\Company.Management.Domain.dll
  Creating metadata from DbContext 'ManagementDbContext'
  Searching for connectionString named 'CompanyDBManagement': not found
  A connection string was not found but metadata discovery has detected that the DefaultConnectionFactory is overridden.
C:\Dev\Dev\MigrationDFandCocktail2012\Company\packages\IdeaBlade.DevForce.Aop.7.0.0-beta1\tools\IdeaBlade.DevForce.Common.targets(110,5): error : An error occurred during metadata generation and a metadata file could not be created.  Error: La référence d'objet n'est pas définie à une instance d'un objet.
  EntityModelMetadataDeploy: No metadata files generated.
Exécution de la tâche "EntityModelMetadataDeploy" terminée -- ÉCHEC.

I first though the problem could come from the connection string but here is the log from model which build :

Creating metadata from DbContext 'StockDbContext'
  Searching for connectionString named ' CompanyDBStock': not found
  A connection string was not found but metadata discovery has detected that the DefaultConnectionFactory is overridden.
  Model metadata created for  CompanyDBStock
  Model metadata for WSoftDBStock.ibmmx is unchanged
Exécution de la tâche "EntityModelMetadataDeploy" terminée.



Any clue what could be the problem ?


Edited by Walid - 24-Sep-2012 at 3:22am
Back to Top
Walid View Drop Down
Senior Member
Senior Member
Avatar

Joined: 14-Nov-2010
Posts: 161
Post Options Post Options   Quote Walid Quote  Post ReplyReply Direct Link To This Post Posted: 22-Sep-2012 at 2:25pm
Updated
Back to Top
Walid View Drop Down
Senior Member
Senior Member
Avatar

Joined: 14-Nov-2010
Posts: 161
Post Options Post Options   Quote Walid Quote  Post ReplyReply Direct Link To This Post Posted: 22-Sep-2012 at 1:05pm
Hi,

I am trying to migrate from 2010 to 2012.

When I try to build I get this error when it was working in the previous with the 6.1.8.

Erreur 1 CodeFirst entities were found in this assembly, but an EntityManager or DbContext was not.  You must define a container for these entities in this assembly. xxx.Common.Domain


This assembly doesn't contains any entitymanager or DBContext because it hosts the base class (all abstract) for all the others domains assemblies.

Is it now mandatory to create a DBContext or entitymanager in any assembly hosting a code first class even if all are abstract  ? 
I created an internal empty entityManager to be able to continue the migration but I feel I shouldn't have to.


Another issue (also working in 6.1.8)  :

Erreur 4 An error occurred during metadata generation and a metadata file could not be created.  Error: You cannot use Ignore method on the property 'AdressPrincipal' on type 'xxx.Global.Domain.Entities.Professional' because this type inherits from the type 'xxx.Global.Domain.Entities.Person' where this property is mapped. To exclude this property from your model, use NotMappedAttribute or Ignore method on the base type. xxx.Global.Domain

I already have the NotMapped attribut on the property AdressPrincipal (below the code)

    [DataContract(IsReference = true)]
    public abstract class Personne : BaseAuditEntity
    {
        [DataMember]
        public int Id { get; set; }

        ...

        [NotMapped]
        public Adresse AdressPrincipal {... }
    }

    public class Professionel : Person
    {
      ...
    }

I don't know, generaly speaking, if I should put the DataContract attribute on  the inherited class if the parent class has it
Anyway I tried both case and both give this error



Edited by Walid - 22-Sep-2012 at 2:24pm
Back to Top
 Post Reply Post Reply Page  <12

Forum Jump Forum Permissions View Drop Down