0

I need to create a schema before the first table is created because it relies on it to exist.

I have tried Add-Migration CreateSchema with and without the flag -IgnoreChanges and then replaced Up and Down methods with my SQL script. The issue is that then, after the command Add-Migration InitialCreate -Verbose creates an empty migration in both cases.

I need to create the schema first because my table attribute [Table("schema.TableName")] in the C# class is in lowercase, but the schema should be in uppercase (SCHEMA).

6
  • 1
    Why do you need to create the scheme in a different migration though? Assuming don't of the table you have configured uses the new schema, then the migration will do all that for you. Commented Feb 4 at 12:10
  • My reason isn't probably good enough. I have lowercase attributes relying on the schema being correct. -> Correct the attributes and move on. But let's say you have an existing db and you need to make sure that your freshly created code-first set up guaranties 1:1 correspondence with the original db. Commented Feb 4 at 12:17
  • I'm sorry, I don't understand what you are saying. What are "lowercase attributes"? It's really unclear what you are trying to do here. I'd really like to see a minimal reproducible example Commented Feb 4 at 12:22
  • Thank you for taking your time on this. I have added an example. Commented Feb 4 at 13:25
  • 1
    First of all, that's not how you specify the schema in a table attribute, you should instead be doing [Table("TableName", Schema: "SchemaName")]. And secondly, if you want it to be capitalised, then you should write it capitalised! Commented Feb 4 at 13:40

0

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.