1

I have a Entity Framework model set up with text templates to generate the code. However, one of them creates the DBContext containing an OnModelCreating.

    protected override void OnModelCreating(DbModelBuilder modelBuilder)
    {
        throw new UnintentionalCodeFirstException();
    }

How do expand on this, since a partial class with the same override does not work.

2 Answers 2

3

You cannot use OnModelCreating when using model first (EDMX). OnModelCreating is only for scenarios without using EDMX.

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

Comments

1

Possibly your problem is that the connection string you're using is a standard SQL Server one rather than the Entity Framework one. See this answer.

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.