Skip to content
Permalink
Browse files

Update Program.cs

Added alternative schema/database name lookup
  • Loading branch information...
DXSdata committed Mar 12, 2019
1 parent 332df61 commit 9393705dcfbcc335da65fb18af8915389f78f130
Showing with 12 additions and 3 deletions.
  1. +12 −3 DotnetEfDbcontextConverter/Program.cs
@@ -36,9 +36,18 @@ static void Main(string[] args)
//Get original schema name
var schemaPosition = content.IndexOf("entity.ToTable(");
var origSchema = content.Substring(schemaPosition, 50);
origSchema = origSchema.Split(",")[1].Trim().Trim('"');
var schemaEndPosition = origSchema.IndexOf('"');
origSchema = origSchema.Substring(0, schemaEndPosition);
try
{
origSchema = origSchema.Split(",")[1].Trim().Trim('"');
var schemaEndPosition = origSchema.IndexOf('"');
origSchema = origSchema.Substring(0, schemaEndPosition);
}
catch(IndexOutOfRangeException) //As an alternative method, use database name from connection string
{
schemaPosition = content.IndexOf("database=");
origSchema = content.Substring(schemaPosition);
origSchema = origSchema.Split(";", 2)[0].Trim().Replace("database=","").Replace("\"", "").Replace(")", "");
}


//Insert static schema variable declaration

0 comments on commit 9393705

Please sign in to comment.
You can’t perform that action at this time.