.net - EF Code First mapping an internal association -



.net - EF Code First mapping an internal association -

i have issue has me stumped. have model assembly , repositories assembly. model layer contains classes mapped our database dbcontext derived repositories in repositories layer. far these have come along without hitch.

in model have 1 many association question 1 - * reply (question.answers , answer.question mapped navigation properties). have requirement mark question.answers internal not create sense outside of model. when create alter from: public virtual ilist<answer> ... internal virtual ilist<answer> ... exception:

a specified include path not valid. entitytype repositories.question not declare navigation property name answers.

first of all, exception odd references type repositories.question, not exist! should model.question.

the model assembly has internalsvisibleto set repositories:

[assembly: internalsvisibleto("repositories")]

which means not compile errors in mapping code , have tried following:

[assembly: internalsvisibleto("entityframework")] [assembly: internalsvisibleto("system.data.entity")]

but still aforementioned exception.

any ideas why getting this?

edit

ladislav mrnka, help! still causing pain.

we have defined relationship using fluent api:

modelbuilder.entity<answer>() .hasrequired(a => a.question) .withmany(q => q.answers) .map(x => x.mapkey("questionid"));

and work when property q.answers set public. info read , written database without issue. when alter internal, our code still compiles (as we're using internalsvisibleto) above exception when run our integration tests.

i have changed connection string new catalog name , ef has no problem creating database , expected constraints. working expected. problem arises when changing navigation property access modifier

regards,

stephen

first of all, exception odd references type repositories.question, not exist! should model.question.

this ef internals behavior. have class called model.question ef internally has called repository.question contained in mapping - same edmx had poco class entity in diagram had "different namespace".

it possible internal navigation property wasn't mapped. can seek create database model , validate relation between answers , questions tables correctly set up? if not seek define relation explicitly fluent api.

.net entity-framework-4 ef-code-first

Comments

Popular posts from this blog

How do I check if an insert was successful with MySQLdb in Python? -

delphi - blogger via idHTTP : error 400 bad request -

postgresql - ERROR: operator is not unique: unknown + unknown -