0

I am using ASP.NET MVC5, entity framework in my web application. It is expected complex business logic so achieving separation in code based on an individual business concern is required. I am using Code First with existing database approach. I have created 3 ADO.NET Entity Data Model in design wizard. so separate dbContext with its model. My issue arise when i created 3rd dbContext which has one table share from one of the model i have created initially. the error is Metadata Exception was unhandle by user code. I believe is something to do with Meta data but not sure how to approach this problem?

what i am trying to achieve, if one webpage (one business function) to only two table, why load whole data in memory plus decoupling will improve maintainability and flexibility to extend application without disturbing existing code!

1 Answer 1

1

The key to using Bounded Contexts is use of

  • Ignore entity

    modelBuilder.Ignore<MyUnNecessaryEntity>();

and/or

  • change the DataBAse initializer on a MINI context to none

    Database.SetInitializer(new ContextInitializerNone<MyContext>());
    

I like teh idea of ONLY 1 context is responsible for keeping a set of tables consistent. The other contexts can access those tables using the same POCO definitions. They can be a subset of pocs. The context is reduced and or has NO initializer.

There is a good article worth a read from Julie Lerman on MSDN on the topic of Bounded Contexts.

Sign up to request clarification or add additional context in comments.

Comments

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Start asking to get answers

Find the answer to your question by asking.

Ask question

Explore related questions

See similar questions with these tags.